1.当控件的属性android:layout_width="match_parent"时,
Button1的Layout_weight=1,Buttong2的Layout_weight=2,运行效果为:
得出结论:在layout_width设置为match_parent的时候,layout_weight代表的是你的控件要优先尽可能的大,但尽可能大是有限度的,即match_parent.
2.当控件的属性android:layout_width="wrap_content"时,
Button1的weight设置为1,Button2的weight设置为2,运行效果为:
效果与match_parent的效果截然相反
3. 当布局的属性android:layout_width="match_parent"时,控件的android:layout_width="0dp":
说明控件所占的长度为0,那个 控件的大小跟weight有关,
Button1的weight设置为1,Button2的weight设置为2,运行效果为:
同于“wrap_content”
在layout_width设置为wrap_content的时候,layout_weight所代表的是你的控件要优先尽可能的小,但这个小是有限度的,即wrap_content.