重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

安卓中linearLayout下android_layout.weight的属性的详细介绍

weight属性,从字面上理解是比重的意思,是和布局里其他部件相比较而言的。

榆阳ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

1:在状态设置再orientation为horizontal、宽度设置为fill_parent、比例一个设置为1,一个设置为2的时候,如截图所示:

安卓中linearLayout下android_layout.weight的属性的详细介绍

此时显示的状态是第一个长度和第二个长度的比例是2:1,就是第一个长度要长一些。

2:现在修改一下放置的状态,修改成垂直放置android:orientation="vertical",其他条件不变,

如下所示:

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   android:orientation="vertical"

   tools:context="com.Test0101_21.MainActivity$PlaceholderFragment" >

   

       android:layout_width="fill_parent"

       android:layout_height="wrap_content"

       android:layout_weight="1"

       android:text="@string/hello_world" />

 

       android:layout_width="fill_parent"

       android:layout_height="wrap_content"

       android:layout_weight="2"

       android:text="@string/hello" />

其运行结果是部件以上下进行排列,第二个部件和第一个部件宽度的比例是2:1,

结论:在水平方向上,比重越大,所显示的面积就越大,比重越小,显示的面积就越小。

     在垂直方向上,比重越大,起显示的面积就越小,比重越小,起显示的面积就越大。

     在水平方向上和垂直方向上其作用是相反的。


网站标题:安卓中linearLayout下android_layout.weight的属性的详细介绍
网页地址:http://cqcxhl.cn/article/giddjp.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP