android_線性佈局常見的幾種佈局形式

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SecondActivity">
    <TextView
        android:textColor="#fff"
        android:background="@color/colorPrimaryDark"
        android:text="top"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="50dp" />
    <TextView
        android:textColor="#fff"
        android:background="@color/colorAccent"
        android:text="bottom"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SecondActivity">
    <TextView
        android:layout_weight="1"
        android:textColor="#fff"
        android:background="@color/colorPrimaryDark"
        android:text="top"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <TextView
        android:textColor="#fff"
        android:background="@color/colorAccent"
        android:text="bottom"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="50dp" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SecondActivity">
    <TextView
        android:layout_weight="1"
        android:textColor="#fff"
        android:background="@color/colorAccent"
        android:text="top"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <TextView
        android:layout_weight="1"
        android:textColor="#fff"
        android:background="@color/colorPrimaryDark"
        android:text="center"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SecondActivity">
    <TextView
        android:textColor="#fff"
        android:background="@color/colorAccent"
        android:text="top"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="50dp" />
    <TextView
        android:layout_weight="1"
        android:textColor="#fff"
        android:background="@color/colorPrimaryDark"
        android:text="center"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <TextView
        android:textColor="#fff"
        android:background="@color/colorAccent"
        android:text="bottom"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="50dp" />
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:layout_height="match_parent"
    tools:context=".SecondActivity">
    
    <TextView
        android:textColor="#fff"
        android:textSize="30sp"
        android:text="左"
        android:gravity="center"
        android:background="@color/colorAccent"
        android:layout_width="wrap_content"
        android:layout_height="50dp" />
    <TextView
        android:gravity="center"
        android:textColor="#fff"
        android:textSize="30sp"
        android:text="右"
        android:background="@color/colorPrimaryDark"
        android:layout_width="match_parent"
        android:layout_height="50dp" />
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".SecondActivity">
    <TextView
        android:layout_weight="1"
        android:textColor="#fff"
        android:background="@color/colorPrimaryDark"
        android:text="left"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="50dp" />
    <TextView
        android:textColor="#fff"
        android:background="@color/colorAccent"
        android:text="right"
        android:textSize="30sp"
        android:gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="50dp" />
</LinearLayout>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章