RelativePopupWindow
RelativePopupWindow copied to clipboard
contentView.getMeasuredWidth() return a wrong result when use .9 image as textview's background.
android:id="@+id/tv_pop_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:background="@drawable/collect_tips"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/sp13" />
public void showOnAnchor(@NonNull View anchor, @VerticalPosition int vertPos, @HorizontalPosition int horizPos, int x, int y, boolean fitInScreen) {
setClippingEnabled(fitInScreen);
View contentView = getContentView();
contentView.measure(makeDropDownMeasureSpec(getWidth()), makeDropDownMeasureSpec(getHeight()));
//i use the layout above ,and collect_tips is a .9 png.
//so,bug occurs,the measuredW is not the real width.
final int measuredW = contentView.getMeasuredWidth();
final int measuredH = contentView.getMeasuredHeight();
i use the layout above ,and collect_tips is a .9 png. so,bug occurs,the measuredW is not the real width.
yes, i find the solution: contentView.post(xxxshowthewindow);