Android LinearLayout example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" android:gravity="center_vertical">
 
    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="White"
        android:textAppearance="?android:attr/textAppearanceLarge" android:background="@color/White" android:textColor="#000000" android:gravity="center_horizontal" android:layout_weight=".5"/>
 
    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Green"
        android:textAppearance="?android:attr/textAppearanceLarge" android:background="@color/Green" android:gravity="center_horizontal" android:layout_weight=".16"/>
 
    <TextView
        android:id="@+id/textView3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Yellow"
        android:textAppearance="?android:attr/textAppearanceLarge" android:background="@color/Yellow" android:textColor="#000000" android:gravity="center_horizontal" android:layout_weight=".16"/>
 
    <TextView
        android:id="@+id/textView4"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Red"
        android:textAppearance="?android:attr/textAppearanceLarge" android:background="@color/Red" android:gravity="center_horizontal" android:layout_weight=".16"/>
 
</LinearLayout>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.