Android LinearLayout 线性布局 |
您所在的位置:网站首页 › layout排版教程 › Android LinearLayout 线性布局 |
LinearLayout 线性布局
LinearLayout 线性布局是安卓最简单的布局,他有两个参数,分别是 vertical 和 horizontal。 vertical 从上到下排版方式: LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 1" / TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 2" / TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 3" / /LinearLayout定义 vertical 方式排版,它会让我们所有的组件从上到下排列,显示如下: Test 1 Test 2 Test 3 ...horizontal 从左到右排版方式: LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 1" / TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 2" / TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 3" / /LinearLayout定义 horizontal 方式排版,它会让我们所有的组件从左到右排列,显示如下: Test 1 Test 2 Test 3 ... 嵌套布局无论你选择哪种布局方式,在安卓中是可以嵌套的,可以在 LinearLayout 布局里面在嵌套一个 LinearLayout 布局。 LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 1" / TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 2" / TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test 3" / LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" // 在嵌套一个 LinearLayout /LinearLayout /LinearLayout |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |