现在的位置: 首页 > 综合 > 正文

Android ApiDemos示例解析(141):Views->Layouts->LinearLayout->1. Vertical

2013年04月21日 ⁄ 综合 ⁄ 共 961字 ⁄ 字号 评论关闭

LinearLayout 将其子View顺序排成一行或是一列,一个垂直列表每行将只有一个子元素(无论它们有多宽),一个水平列表只是一列的高度(最高子元素的高度来填充)。

本例介绍了LinearLayout 的基本用法,LinearLayout的方向可以使用android:orientation 来定义,可以指定vertical 或是 horizontal ,缺省为横向horizontal。

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

<!– view1 goes on top –>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_1_top”/>

<!– view2 goes in the middle –>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_1_middle”/>

<!– view3 goes on the bottom –>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_1_bottom”/>

</LinearLayout>

抱歉!评论已关闭.