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

0  comments

RelativeLayout is your best friend if you want to make a flexible UI. You can position its child views relative to the layout itself or relative to other views.

 

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

Main.axml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/second"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#2196F3"
        android:textSize="70sp"
        android:text="2nd" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/second"
        android:layout_toRightOf="@id/second"
        android:background="#F44336"
        android:textSize="70sp"
        android:text="1st" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/second"
        android:layout_toLeftOf="@id/second"
        android:background="#4CAF50"
        android:textSize="70sp"
        android:text="3rd" />
</RelativeLayout>

 

About the author 

Matt Rešetár

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

You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>