Android layout can';无法使android自定义对话框大小正确
我试图创建一个自定义对话框,但它既使其与屏幕一样宽(减去填充),更重要的是,它在第一个文本视图上方的顶部增加了一英寸左右的白色(背景色为红色)。我想要的是一个与填充内容所需的对话框一样大的对话框 如果我将任何布局从fill_parent更改为wrap_content,我会得到与图像大小有关的内容,其他所有内容(即文本)都会被截断 我做错了什么Android layout can';无法使android自定义对话框大小正确,android-layout,Android Layout,我试图创建一个自定义对话框,但它既使其与屏幕一样宽(减去填充),更重要的是,它在第一个文本视图上方的顶部增加了一英寸左右的白色(背景色为红色)。我想要的是一个与填充内容所需的对话框一样大的对话框 如果我将任何布局从fill_parent更改为wrap_content,我会得到与图像大小有关的内容,其他所有内容(即文本)都会被截断 我做错了什么 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/customdialog"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/titledialog"
android:orientation="vertical" >
<TextView
android:id="@+id/textTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/titleback"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="24dp"
android:paddingTop="48dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<Button
android:id="@+id/buttonCustomDialogOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Close" />
我在这里找到了答案
显然,顶部空白位是布局的标题,除非使用AlertDialog而不是Dialog,否则无法删除它
啊,谢谢你的更新。
您可以这样做Dialog Dialog=新建对话框(context,R.style.FullHeightDialog);
(或者试试这个)
getDialog().getWindow().requestFeature(Window.FEATURE\u NO\u TITLE) 白色部分不代表标题?可能,我是这么想的,但如何摆脱它呢?此外,这仅适用于JB,如果我在姜饼上运行相同的对话框,则对话框是图像的宽度,几乎所有文本都会丢失,请检查如何删除标题。