如何在屏幕底部显示小部件按钮。
我想在屏幕底部显示“发送”按钮。
附上截图:
以下是布局xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/to"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/subject"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/message"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:text="@string/send"/>
</LinearLayout>
选中上方的按钮(发送),我想在屏幕底部显示此按钮。我该怎么办。我已将android:layout_gravity = 0.0用于按钮小部件,但不起作用。
轻松使用相对布局而不是LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<EditText
android:id="@+id/to"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="to"/>
<EditText
android:id="@+id/sub"
android:layout_below="@id/to"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="subject"/>
<EditText
android:id="@+id/msg"
android:layout_below="@id/sub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="message"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="send"/>
</RelativeLayout>
在LinearLayout中,您将无法执行此操作。希望能帮助到你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句