转自:http://segmentfault.com/q/1010000000095725
如果使得一个View占用其父View的剩余空间?
答案是使用:android:layout_weight = "1"
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffe0e8ec" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="20dip" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="20dip" /> </LinearLayout>
android:layout_weight的解释:
Layout weight is used to determine how Android divides up any left over space after the various widgets get all of the space they want.