layout_weight应用技巧

1、layout_weight:只是分配父控件的剩余空间

如:现有两个控件,A,B,父控件还有剩余空间,但我想让A占有剩余空间的1份,B占有剩余空间的2份。将A控件的android:layout_weight="1"设置成1,再将B控件的android:layout_weight="2"设置成2即可

2、现有A,B两个控件,我想把A控件占有父控件的1/3,B控件占有父控件的2/3

将A控件的android:layout_width="0dp"设置为0,再将android:layout_weight="1"设置成1

再将B控件的android:layout_width="0dp"设置为0,再将android:layout_weight="2"设置成2

 此方法,性能很好

原文地址:https://www.cnblogs.com/zhouli1980/p/layout_weight.html