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

8  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 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
  • Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  • Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  • Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

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