最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android layout 按比例布局的代碼

 更新時(shí)間:2013年03月17日 21:07:51   作者:  
android layout 按比例布局的代碼,需要的朋友可以參考一下

為了創(chuàng)建比例大小的子View,可以將LinearLayout的寬度和高度設(shè)為fill_parent, 而將子View的寬度或是高度設(shè)為0,然后為子View設(shè)置不同權(quán)重(weight) ,這樣子View的大小就會(huì)權(quán)值成比例。

本例使用橫向LinearLayout,LinearLayout的android:layout_width=”match_parent”,表示將使用整個(gè)屏幕寬度。

對(duì)于LinearLayout的幾個(gè)子View,將它們的寬度都定義為0,android:layout_width=”0dip”,然后使用layout_weight 為每個(gè)View指定寬度比例,本例為每個(gè)TextView都使用了相同的權(quán)值,因此四個(gè)TextView將會(huì)有相同的寬度。這樣對(duì)于那些顯示文字比較長(zhǎng)的TextView的高度就變?yōu)槎嘈小?BR>

復(fù)制代碼 代碼如下:

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”android:orientation=”horizontal”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>

<TextView
android:background=”@drawable/red”
android:layout_width=”0dip”
android:layout_height=”match_parent”
android:layout_weight=”1″
android:text=”@string/linear_layout_7_small”/>

<TextView
android:background=”@drawable/green”
android:layout_width=”0dip”
android:layout_height=”match_parent”
android:layout_weight=”1″
android:text=”@string/linear_layout_7_big”/>

<TextView
android:background=”@drawable/blue”
android:layout_width=”0dip”
android:layout_height=”match_parent”
android:layout_weight=”1″
android:text=”@string/linear_layout_7_small” />

<TextView
android:background=”@drawable/yellow”
android:layout_width=”0dip”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:text=”@string/linear_layout_7_wrap”/>

</LinearLayout>

相關(guān)文章

最新評(píng)論

南华县| 武城县| 土默特右旗| 睢宁县| 河北省| 夏津县| 阳东县| 油尖旺区| 北安市| 宜都市| 祥云县| 肃南| 敖汉旗| 呼玛县| 闽侯县| 工布江达县| 仁化县| 新田县| 容城县| 兴隆县| 大庆市| 依兰县| 铁岭县| 翁牛特旗| 宁都县| 得荣县| 沅陵县| 龙南县| 密山市| 镇原县| 忻州市| 大兴区| 加查县| 驻马店市| 通山县| 拉萨市| 永丰县| 长宁区| 西安市| 镇雄县| 金坛市|