关于Android中权重问题

来源:互联网 发布:java访问nas存储空间 编辑:程序博客网 时间:2024/05/19 18:48

权重问题不仅限于各个控件之间,也可用于布局之间。(不知道用词对不,初学者,请见谅)这两个布局之间就用权重的方法得到了最终3:1的比例。在layout_width设置为fill_parent的时候,layout_weight所代表的是你的控件要优先尽可能的大,但这个大是有限度的,即fill_parent.在layout_width设置为wrap_content的时候,layout_weight所代表的是你的控件要优先尽可能的小,但这个小是有限度的,即wrap_content.要真正的明白必须自己亲手试一试其中的区别。



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       android:layout_width="fill_parent"       android:layout_height="fill_parent"       android:orientation="horizontal" ><LinearLayout     android:orientation="vertical"   android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" </LinearLayout> <LinearLayoutandroid:orientation="vertical"  android:layout_width="wrap_content" android:layout_height="fill_parent"  android:layout_weight="3"  </LinearLayout></LinearLayout>