首页 > 其他 > 详细

layout_weight

时间:2014-01-16 20:32:22      阅读:357      评论:0      收藏:0      [点我收藏+]

比如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="10dip"
    style="?android:attr/buttonBarStyle"
    >
    <Button
        style="?android:attr/buttonBarButtonStyle"
        android:id="@+id/uploadpb"
        android:layout_weight="1"
        android:layout_width= "10dip"
        android:layout_height="wrap_content"
        android:text="@string/uploadpb" />
    <Button
        style="?android:attr/buttonBarButtonStyle"
        android:id="@+id/downloadpb"
        android:layout_weight="1"
        android:layout_width= "10dip"
        android:layout_height="wrap_content"
        android:text="@string/downloadpb"
        />      
</LinearLayout>

  

 

  在这个水平布局的线性布局中,我给每个按钮任意一个layout_width(否则编译时会报错),给每个按钮一个「android:layout_weight="1"」,这样就均等分配了水平空间,like this:

  bubuko.com,布布扣

  

    用layout_weight是为了适应不同android设备的不同屏幕分辨率

layout_weight

原文:http://www.cnblogs.com/larrylawrence/p/3518449.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!