我正在使用android中的自定义alertDialog,并发现一个问题。我的代码很简单:android中的自定义alertDialog
LayoutInflater inflatre = getLayoutInflater();
View v = inflatre.inflate(R.layout.dialog_view, null);
AlertDialog.Builder dialog = new AlertDialog.Builder(EditPageActivity.this);
dialog.setView(v);
dialog.show();
而且布局XML是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg"
android:padding="10dp"
android:gravity="center" >
<Button
android:id="@+id/gallery_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gallery" />
<Button
android:id="@+id/photo_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/gallery_b"
android:text="Take Photo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/gallery_b"
android:layout_centerHorizontal="true"
android:text="Choose Image"
android:textSize="20sp"
android:textColor="@color/splash_font"
android:layout_marginBottom="10dp" />
但输出是这样的:
感觉谷歌搜索后无奈:(......任何人都可以形容我的任何东西
集'的android:layout_width = “FILL_PARENT” 机器人:layout_height = “FILL_PARENT”'到主布局,并尝试 –
删除填充或使用对话背景图像的高度较大或只是手动设置布局的高度 –