android - 如何在屏幕底部显示小部件android

标签 android android-layout

如何在屏幕底部显示小部件按钮。

我想在屏幕底部显示发送按钮

附上截图:

enter image description here

下面是布局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/

相关文章:

java - 微调器的 OnItemClickListener

java - 由于图像按钮强制关闭

android - 如何在cardview中水平和垂直放置相等的空间

Android - ImageView 覆盖另一个 ImageView

java - 如何将带有 Imageview 和 TextView 的 RelativeLayout 转换为 PNG 图像?

android - 如何在单个 Android 应用程序中维护两个不同的版本

android - 在Unity中,如何构建和播放WebGL项目并在Android设备上播放?

android - 用于并行编程的 HashMap

java - INSTALL_PARSE_FAILED_NO_CERTIFICATES 安装修改后的 apk 文件失败(无效的 SHA1 签名),即使在使用 jarsigner 签名之后

android - 使用 fragment 时出现空指针错误