我有一个应用程序,我打开一个PopupWindow,在tex框下面有几个图像,一个文本框和一个垃圾桶的图标。
问题在于我正在展示PopupWindow,有时当我打开窗口时图标看起来很小,而在其他时候(大多数时候),图标看起来像我定义的那样。 / p>
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>
答案 0 :(得分:0)