RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
安卓中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的属性的详细介绍
URL网址:http://scyingshan.cn/article/giddjp.html