LINEAR LAYOUT – Quick Tutorial (Xamarin Android) (Code)

4  comments

LinearLayout is one of the most basic layouts in Android. It’s used to easily group individual views together in either vertical or horizontal direction.

Linear layout is also very practical because it supports weight. This makes the child views “stretch” to fill out the space in the layout.

 

This post contains all the code that’s been written in this YouTube video.

Main.axml

<?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="wrap_content"
        android:layout_height="0dp"
        android:background="#F44336"
        android:textSize="70sp"
        android:text="1st"
        android:layout_weight="1" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:background="#2196F3"
        android:textSize="70sp"
        android:text="2nd"
        android:layout_weight="1" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:background="#4CAF50"
        android:textSize="70sp"
        android:text="3rd"
        android:layout_weight="2" />
</LinearLayout>

 

About the author 

Matt Rešetár

Matt is an app developer with a knack for teaching others. Working as a Flutter Developer at LeanCode and a developer educator, he is set on helping other people succeed in their Flutter app development career.

You may also like

Flutter UI Testing with Patrol

Flutter UI Testing with Patrol
  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    >