android layout_weight了解

 

1、当控件的属性android:layout_width="fill_parent"时,布局文件设置的android:layout_weight成反比关系。

  如:button1 设置android:layout_weight="1",button2设置 android:layout_weight="2",则button1和button的长度比是2:1,成为反比。

 

2、当控件的属性android:layout_width="wrap_content"时,布局文件设置的android:layout_weight成正比关系。

  如:button1 设置android:layout_weight="1",button2设置 android:layout_weight="2",则button1和button的长度比是1:2,成为正比。

 

 

 

3、如果一行中有2个组件,想要设置第一个组件固定大小,第二个组件填充所有的空间,可以设置第二个组件为

      android:layout_width="fill_parent"和android:layout_weight="1"。

你可能感兴趣的:(android layout_weight了解)