Android 的 PopupWindow 上的图标有问题

Issue with an icon on Android's PopupWindow

我有一个应用程序,我在其中打开了一个 PopupWindow,在 tex 框下方有几个图像、一个文本框和一个垃圾桶图标。

问题是当我显示 PopupWindow 时,有时当我打开 window 时图标看起来很小,而在其他时候(大多数时候)图标看起来像我定义的那样.

popUpView = inflater.inflate(R.layout.activity_packpresent, (ViewGroup)ma.findViewById(R.layout.activity_main));

pw = new PopupWindow(
        popUpView,
        ma.f.getView().getMeasuredWidth(), //400
        ma.f.getView().getMeasuredHeight(), //800
        true);
pw.setOnDismissListener(new PopupWindow.OnDismissListener() {
    @Override
    public void onDismiss() {
        System.out.println("Dismissed!!");

        Handler handler = new Handler();
        handler.post(new Runnable() {

            @Override
            public void run() {
                //MainActivity.packButton.setVisibility(View.VISIBLE);
                try {
                    image.recycle();
                } catch (Exception e) {
                }
                ma.handlePopUpDissmiss();
            }
        });
    }
});

trash = (ImageButton)popUpView.findViewById(R.id.trashBin);
trash.getLayoutParams().height = (int)((MainActivity.wantedPicSize)*(3.0/4.0));
trash.getLayoutParams().width = (int)((MainActivity.wantedPicSize)*(3.0/4.0));

pw.showAtLocation(map, Gravity.BOTTOM, 0, 0);
pw.update();

布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/lID">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/rID"
        android:background="@drawable/back5">

        <ImageView
            android:layout_width="125px"
            android:layout_height="200px"
            android:id="@+id/mImageView"
            android:background="@drawable/com_facebook_picker_default_separator_color"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/editText"
            android:layout_below="@+id/mImageView"
            android:layout_marginTop="50dp"
            android:editable="false"
            android:visibility="visible"
            android:layout_alignRight="@+id/imageViewR"
            android:layout_alignEnd="@+id/imageViewR"
            android:layout_alignLeft="@+id/imageViewL"
            android:layout_alignStart="@+id/imageViewL" />

        <ImageView
            android:layout_width="125px"
            android:layout_height="200px"
            android:id="@+id/imageViewRR"
            android:background="@drawable/com_facebook_picker_default_separator_color"
            android:layout_alignTop="@+id/imageViewR"
            android:layout_toRightOf="@+id/button" />

        <ImageView
            android:layout_width="125px"
            android:layout_height="200px"
            android:id="@+id/imageViewLL"
            android:background="@drawable/com_facebook_picker_default_separator_color"
            android:layout_alignTop="@+id/imageViewL"
            android:layout_toLeftOf="@+id/button" />

        <ImageView
            android:layout_width="125px"
            android:layout_height="200px"
            android:id="@+id/imageViewR"
            android:background="@drawable/com_facebook_picker_default_separator_color"
            android:layout_alignTop="@+id/mImageView"
            android:layout_toRightOf="@+id/mImageView" />

        <ImageView
            android:layout_width="125px"
            android:layout_height="200px"
            android:id="@+id/imageViewL"
            android:background="@drawable/com_facebook_picker_default_separator_color"
            android:layout_above="@+id/editText"
            android:layout_toLeftOf="@+id/mImageView" />

        <GridView
            android:layout_width="300dp"
            android:layout_height="300dp"
            android:id="@+id/gridView"
            android:layout_above="@+id/mImageView"
            android:layout_centerHorizontal="true"
            android:visibility="invisible"
            android:layout_marginBottom="10dp"
            android:layout_below="@+id/button2" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button"
            android:layout_below="@+id/editText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="70dp"
            android:visibility="invisible" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="10dp"
            android:id="@+id/imageView"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10dp"
            android:layout_alignRight="@+id/imageViewRR"
            android:background="@drawable/line"
            android:layout_alignLeft="@+id/imageViewLL"
            android:layout_below="@+id/gridView" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="20dp"
            android:text="New Button"
            android:id="@+id/button2"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/imageViewRR"
            android:visibility="invisible" />

        <ImageButton
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/trashBin"
            android:layout_below="@+id/editText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:background="@drawable/trash_bin" />

    </RelativeLayout>

</LinearLayout>

您可以尝试使用可在此处生成的 .9 补丁图像:.9 patch generator

或者您可以在这里使用这些图标生成器中的任何一个,看看是否可行:Android Asset Studio

这两个链接都非常有用。