首页 > 其他 > 详细

Display layout of linerlayout by %

时间:2014-04-14 03:47:12      阅读:479      评论:0      收藏:0      [点我收藏+]


If we want to display components of LinearLayout by %.we neet to set android:layout:widh:"0dp".if the orientation is vertical,we need to set android:layout_height="0dp".under this circumstance ,one of components‘s space scale is itself weight/sum of all the components weight in the LinearLayout.

let me see the demo:

<LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
         >
            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="#aa0000"
                    android:gravity="center"
                    android:text="1"/>
            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="2"
                    android:background="#00aa00"
                    android:gravity="center"
                    android:text="1"/>
            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="3"
                    android:background="#0000aa"
                    android:gravity="center"
                    android:text="1"/>
    </LinearLayout>

the effect is:

bubuko.com,布布扣

Display layout of linerlayout by %,布布扣,bubuko.com

Display layout of linerlayout by %

原文:http://blog.csdn.net/howlaa/article/details/23612995

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