1.用linearlayout线性布局:
android:layout_height="0dp" <!-- 高度设为0dp -->
android:layout_weight="1" <!--layout_weight=1,确保底部的LinearLayout到底部 -->
2. 用RelativeLayout相对布局:
android:layout_alignParentBottom="true" <!-- 设置底部对齐,这个属性上级是RelativeLayout -->
线性布局举例如下:
<LinearLayout
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="0dp" <!-- 设置为0dp>
android:layout_weight="1" <!-- 设置layout_weight=1>
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false" />
</LinearLayout>
</LinearLayout>