有人告诉我创建自定义布局来更改对话框的默认大小。我似乎无法让它工作。
这是构建对话框的位置:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
AlertDialog ad = builder.create();
LayoutInflater inflater = context.getLayoutInflater();
builder.setView(inflater.inflate(R.layout.dialog_layout, null));
ad.setMessage("message");
ad.show();
这是布局 XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<View android:id="@+id/dialog_view"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_weight="1" />
</FrameLayout>