我有一个TextView
,我想将它固定在一个使用垂直排列元素的LinearLayout
的景观活动的底部。
我已经在文本视图上设置了android:gravity="bottom"
,但它仍然希望恰好位于LinearLayout
的最后一个元素之下,这正是我不希望它做的事情。
有什么建议吗?
发布于 2011-03-25 04:54:03
您必须展开上面的一个视图,通过在其上设置android:layout_weight="1"
来填充剩余空间。这将把您的最后一个视图推到底部。
以下是我的意思的简要概述:
<LinearLayout android:orientation="vertical">
<View/>
<View android:layout_weight="1"/>
<View/>
<View android:id="@+id/bottom"/>
</LinearLayout>
其中每个子视图的高度都是"wrap_content"
,其他的都是"fill_parent"
。
发布于 2014-10-01 19:53:53
我认为这将是一个完美的解决方案:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Other views -->
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<!-- Target view below -->
<View
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
发布于 2014-09-24 13:36:21
步骤1:在线性布局中创建两个视图
步骤2: First view必须设置为android:layout_weight="1“
第三步:自动向下推送第二个视图
<LinearLayout
android:id="@+id/botton_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/btn_health_advice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
https://stackoverflow.com/questions/5425341
复制相似问题