layout_weight

在layout_width設置為fill_parent的時候,layout_weight所代表的是你的控件要優先盡可能的大,但這個大是有限度的,即fill_parent.

在layout_width設置為wrap_content的時候,layout_weight所代表的是你的控件要優先盡可能的小,但這個小是有限度的,即wrap_content.

layout_height 同 layout_width.

1. layout_width="fill_parent", button1的weight=1,button2的weight=2;

 

2.layout_width="fill_parent", button1的weight=1,button2的weight=2000;

 

------------------------------------------------------------------------------------------------------------------------------------------------

 

3.layout_width="wrap_content", button1的weight=1,button2的weight=2;

 

 

 

4.layout_width="wrap_content", button1的weight=1,button2的weight=2000;

 

原文地址:https://www.cnblogs.com/lyz459/p/3785371.html