1.LinearLayout中,将某一组件或布局放置于底部
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:background="#00aaff">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="25sp"
android:text="80%"
/>
</LinearLayout>
</LinearLayout>
关键语句:
android:gravity="bottom"
2.RelativeLayout中,将某一组件或布局放置于底部
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="25dp"
android:background="#00aaff">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="25sp"
android:text="80%"
/>
</LinearLayout>
</RelativeLayout>
关键语句:
android:layout_alignParentBottom="true"
效果图都是一样的: