1. 采用 linearlayout 布局:
Android:layout_height="0dp" 这里不能设置 fill_parent -->
Android:layout_weight="1" 这里设置 layout_weight=1 是最关键的, 否则底部的 LinearLayout 无法到底部 -->
2. 采用 relativelayout 布局:
Android:layout_alignParentBottom="true" 这里设置 layout_alignParentBottom=true 是最关键的, 这个属性上级必须是 RelativeLayout -->
=====================================
布局 xml 代码如下:
1) 采用 linearlayout 布局
- xmlns:Android="http://schemas.android.com/apk/res/android"
- Android:layout_width="match_parent" Android:layout_height="match_parent"
- Android:orientation="vertical">
- Android:layout_height="0dp"
- Android:layout_weight="1"
- Android:orientation="vertical">
- Android:layout_width="match_parent" Android:layout_height="wrap_content"
- Android:gravity="bottom" Android:orientation="vertical">
- Android:layout_width="wrap_content" Android:layout_height="wrap_content"
- Android:background="#ff0000" Android:focusable="false" />
2) 采用 relativelayout 布局
- xmlns:Android="http://schemas.android.com/apk/res/android"
- Android:layout_width="match_parent" Android:layout_height="match_parent"
- Android:orientation="vertical">
- Android:layout_alignParentBottom="true"
- Android:orientation="vertical">
- Android:layout_width="match_parent" Android:layout_height="wrap_content"
- Android:background="#ff0000" Android:focusable="false" Android:text="button"
- />
本博客地址: https://www.cnblogs.com/wukong1688/
来源: http://www.bubuko.com/infodetail-3012800.html