Android 将按钮添加到自定义对话框';s布局(dialog.xml)
谢谢大家的回答,在跟随你们的回复之后,我设法从下面的代码中得到了类似的东西,但是我仍然有一些修正。请尝试帮助。 dialog.xmlAndroid 将按钮添加到自定义对话框';s布局(dialog.xml),android,xml,android-relativelayout,customdialog,Android,Xml,Android Relativelayout,Customdialog,谢谢大家的回答,在跟随你们的回复之后,我设法从下面的代码中得到了类似的东西,但是我仍然有一些修正。请尝试帮助。 dialog.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="wrap_content" android:layout_height=
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listViewDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_below="@+id/ImageView1" >
</ListView>
<CheckBox
android:id="@+id/checkBoxAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/listView1"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dp"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp"
android:text="" />
<ImageView
android:id="@+id/ImageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="15dp"
android:layout_marginLeft="14dp"
android:layout_marginTop="15dp"
android:background="#FFFFBB33"
android:contentDescription="@string/app_name"
android:scaleType="center"
android:src="@drawable/alert_dialog_icon" />
<TextView
android:id="@+id/textView1"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_above="@+id/listViewDialog"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@+id/ImageView1"
android:gravity="center_vertical"
android:text="Categories"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_toLeftOf="@+id/checkBoxAll"
android:text="All"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="OK" />
</RelativeLayout>
试试这个,我已经修改了你的布局:
<ListView
android:id="@+id/listViewDialog"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/ImageView1"
android:layout_above="@+id/button1" >
</ListView>
<CheckBox
android:id="@+id/checkBoxAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/listView1"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dp"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp"
android:text="" />
<ImageView
android:id="@+id/ImageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="15dp"
android:layout_marginLeft="14dp"
android:layout_marginTop="15dp"
android:background="#FFFFBB33"
android:contentDescription="@string/app_name"
android:scaleType="center"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_above="@+id/listViewDialog"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@+id/ImageView1"
android:gravity="center_vertical"
android:text="Categories"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_toLeftOf="@+id/checkBoxAll"
android:text="All"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="OK"
android:layout_centerHorizontal="true"
/>
试试这个,我已经修改了你的布局:
<ListView
android:id="@+id/listViewDialog"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/ImageView1"
android:layout_above="@+id/button1" >
</ListView>
<CheckBox
android:id="@+id/checkBoxAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/listView1"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dp"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp"
android:text="" />
<ImageView
android:id="@+id/ImageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="15dp"
android:layout_marginLeft="14dp"
android:layout_marginTop="15dp"
android:background="#FFFFBB33"
android:contentDescription="@string/app_name"
android:scaleType="center"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_above="@+id/listViewDialog"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@+id/ImageView1"
android:gravity="center_vertical"
android:text="Categories"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_toLeftOf="@+id/checkBoxAll"
android:text="All"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="OK"
android:layout_centerHorizontal="true"
/>
试试这个:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="OK"
android:layout_below="@id/textView2"
android:layout_centerHorizontal="true"
/>
在Android Cracker的代码中。试试这个:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="OK"
android:layout_below="@id/textView2"
android:layout_centerHorizontal="true"
/>
在Android Cracker的代码中。您是否尝试过在相对布局下添加按钮(我的意思是-到另一个父布局中)?您的意思是在相对布局中添加相对布局。?我的意思是创建一个新的父布局并在其中添加两个其他布局:1)您当前的布局2)使用按钮的布局请检查我的问题以进行编辑。谢谢。将android:layout\u alignParentLeft=“true”更改为android:layout\u alignParentCenter=“true”您是否尝试在相对布局下方添加按钮(我的意思是-添加到另一个父布局中)?你指的是相对布局中的相对布局。?我指的是制作一个新的父布局,并在其中放入两个其他布局:1)当前布局2)带按钮的布局请检查我的问题以进行编辑。谢谢。将android:layout\u alignParentLeft=“true”更改为android:layout\u alignParentCenter=“true”我尝试使用您的代码,但仍有一些问题需要解决。我已经粘贴了截图。查看我编辑的问题。您能详细说明一下您希望如何设计布局吗?我会帮助您的。我只想删除列表视图和对话框中按钮之间的空格。这就是我想要的。看这个问题:我想,你需要给listview指定固定的高度,而不是包装内容,并从按钮标签中删除android:layout\u alignParentBottom=“true”,这是我在你的代码中尝试过的,但仍有一些问题需要解决。我已经粘贴了截图。查看我编辑的问题。您能详细说明一下您希望如何设计布局吗?我会帮助您的。我只想删除列表视图和对话框中按钮之间的空格。这就是我想要的。看这个问题:我想,你需要给listview指定固定的高度,而不是包装内容,并从按钮标签中删除android:layout\u alignParentBottom=“true”,这就是我从你的代码中得到的按钮,但没有正确的对齐方式,我再次编辑了我的问题,请检查。?我从您的代码中获取按钮,但没有正确对齐,我已再次编辑我的问题,请检查。?