Android LinearLayout 线性布局
示例
LinearLayout是一种ViewGroup将其子级排列在单列或单行中的。可以通过调用方法setOrientation()或使用xml属性来设置方向android:orientation。
垂直方向:android:orientation="vertical"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@android:string/cancel" />
</LinearLayout>这是一个屏幕截图,看起来像这样:
水平方向:android:orientation="horizontal"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@android:string/cancel"/>
该LinearLayout还支持分配权重,以个别儿童与android:layout_weight属性。
热门推荐
10 老师对学校祝福语简短
11 写给情侣祝福语 浪漫简短
12 宝宝周岁敬酒祝福语简短
13 娶嫂子的祝福语简短
14 别人过大寿祝福语简短
15 送给老师中秋祝福语简短
16 新疆新年祝福语大全简短
17 牛年女神节祝福语简短
18 近代生日祝福语简短精辟