Android Studio-06【LinearLayout線性佈局: layout_weight 比重(顏色漸層)-1】

 

 <LinearLayout> android:layout_weight

vertical
(1:2:3:4:5)


   【activity_main.xml

     As the following code:

 
<?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=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Test1"
android:background="#1e90ff"
android:layout_weight="1"/>

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Test2"
android:background="#00bfff"
android:layout_weight="2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Test3"
android:background="#87cefa"
android:layout_weight="3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Test4"
android:background="#e0ffff"
android:layout_weight="4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Test5"
android:background="#f0ffff"
android:layout_weight="5"/>


</LinearLayout>