首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

Android ApiDemos示范解析(146):Views->Layouts->LinearLayout->6. Uniform Size

2012-09-04 
Android ApiDemos示例解析(146):Views-Layouts-LinearLayout-6. Uniform Size本例使用给LinearLayout

Android ApiDemos示例解析(146):Views->Layouts->LinearLayout->6. Uniform Size

本例使用给LinearLayout 宽度和高度设为wrap_content 和将子View大小设为match_parent ,从而实现所有子View具有同样的大小:

  • wrap_content: 告诉View使用能包含其内容的尺寸 (类似于WinForm 中AutoSize)。
  • fill_parent(或match_parent 从Level 8起): 子View扩展为其父容器尺寸。

    <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
    android:orientation=”vertical”
    android:background=”@drawable/blue”
    android:padding=”20dip”
    android:layout_width=”wrap_content”
    android:layout_height=”wrap_content“>

    <TextView
    android:background=”@drawable/box”
    android:layout_width=”match_parent”
    android:layout_height=”wrap_content”
    android:text=”@string/linear_layout_6_one”/>

    <TextView
    android:background=”@drawable/box”
    android:layout_width=”match_parent”
    android:layout_height=”wrap_content”
    android:text=”@string/linear_layout_6_two”/>

    <TextView
    android:background=”@drawable/box”
    android:layout_width=”match_parent”
    android:layout_height=”wrap_content”
    android:text=”@string/linear_layout_6_three”/>

    <TextView
    android:background=”@drawable/box”
    android:layout_width=”match_parent”
    android:layout_height=”wrap_content”
    android:text=”@string/linear_layout_6_four”/>

    </LinearLayout>

    Android ApiDemos示范解析(146):Views->Layouts->LinearLayout->6. Uniform Size

     

热点排行