如何在屏幕底部显示小部件按钮。
我想在屏幕底部显示发送按钮。
附上截图:
下面是布局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 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"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom|right">
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/send"/>
</LinearLayout>
</LinearLayout>
关于android - 如何在屏幕底部显示小部件android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25159572/