欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android layout 按比例布局的代碼

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

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

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

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

復制代碼 代碼如下:

<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>

相關文章

最新評論