我是android的新手,我的android UI有问题。我想将“确定”按钮放在对话框对话框中的行的边缘。我怎样才能做到这一点。
The xml i am using for now is this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="defedfg"
android:textSize="20sp"/>
<Button
android:id="@+id/dialogButton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/blue_button_xhdpi"
android:text="@string/ok"
android:layout_marginTop="30dp"
android:textColor="#f7f6f5"/>
</LinearLayout>
它的解决方案非常简单。给“接受一个父级布局”,并在内部“接受一个LinearLayout和一个”按钮。然后在“布局子项”上保留一些边距
这是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="300dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="20dp"
android:background="@android:color/black"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@android:color/white" >
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="OK" />
和输出
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句