使用LinearLayout将按钮对齐到底部

奥利奥

尝试使用LinearLayout在底部对齐按钮,但正好位于TextView下方。

要将按钮设置在底部,我正在使用android:layout_gravity="bottom"但仍未完成

LinearLayout XML

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="0dp"
        android:layout_height="match_parent"            
        android:orientation="vertical" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_gravity="bottom"
            android:layout_height="wrap_content">

            <Button
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="Bottom" />

        </LinearLayout>

 </LinearLayout>
安吉·阿格瓦尔(Ankit Aggarwal)

将第二个线性布局更改为

<LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="horizontal" >

这会将按钮置于底部,此布局将占用其余空间

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

将Div中的按钮对齐到底部

来自分类Dev

将浮动div对齐到底部

来自分类Dev

将表格水平对齐到底部中心

来自分类Dev

无法将 div 居中对齐到底部

来自分类Dev

如何在LinearLayout中对齐屏幕底部的按钮

来自分类Dev

如何在LinearLayout中对齐屏幕底部的按钮

来自分类Dev

在 RelativeLayout 的底部对齐 LinearLayout

来自分类Dev

小程序-将文本对齐到底部中间

来自分类Dev

将div对齐到底部而不将其从流中删除

来自分类Dev

将列表项垂直对齐到底部

来自分类Dev

我无法将元素垂直对齐到底部

来自分类Dev

如何将div中的sth对齐到底部?

来自分类Dev

将 Bootstrap 4 导航栏链接对齐到底部

来自分类Dev

将按钮对齐到布局的底部

来自分类Dev

仅使用CSS尝试使最右边的div对齐到底部

来自分类Dev

Braintree dropin将贝宝按钮移到底部?

来自分类Dev

LinearLayout 在底部推出按钮

来自分类Dev

底部对齐按钮Bootstrap

来自分类Dev

CSS按钮对齐底部

来自分类Dev

如何使用LinearLayout将TextView右对齐

来自分类Dev

使用flex将项目与底部对齐

来自分类Dev

Android表行对齐到底部

来自分类Dev

在Android中将RelativeLayout对齐到底部

来自分类Dev

使用appendTo将列表项移到底部

来自分类Dev

使用引导程序将元素定位到底部

来自分类Dev

将线性布局中的按钮与屏幕底部对齐

来自分类Dev

如何正确将按钮输入与表格底部的右侧对齐?

来自分类Dev

将文本在按钮底部和背景前面对齐

来自分类Dev

将线性布局中的按钮与屏幕底部对齐