If we want to display components of LinearLayout by %.we neet to set android:layout:widh:"0dp".if the orientation is vertical,we need to set android:layout_height="0dp".under this circumstance ,one of components‘s space scale is itself weight/sum of all the components weight in the LinearLayout.
let me see the demo:
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:background="#aa0000" android:gravity="center" android:text="1"/> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="2" android:background="#00aa00" android:gravity="center" android:text="1"/> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="3" android:background="#0000aa" android:gravity="center" android:text="1"/> </LinearLayout>
Display layout of linerlayout by %,布布扣,bubuko.com
Display layout of linerlayout by %
原文:http://blog.csdn.net/howlaa/article/details/23612995