您的位置:首页 > 移动开发 > Android开发

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

2012-08-26 08:53 483 查看
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>



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐