Linear Layout Views

Ques. : How to Set Center & Horizontal Alignment for All Different Views in Android using XML code in Linear Layout Views.
<?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:contentDescription="@string/app_name"
    android:orientation="vertical"
    tools:context=".MainActivity"
    
    android:gravity="center_horizontal">
</LinearLayout>
Ques. : How to Set Background Color/Image for All Different Views in Android using XML code in Linear Layout Views.
<?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:contentDescription="@string/app_name"
    android:orientation="vertical"
    tools:context=".MainActivity"

    android:layout_margin="20dp"

    android:background="@color/green"  <!-- for Background Color -->
    android:background="@drawable/image1">  <!-- for Background Image -->
</LinearLayout>
Ques. : How to Set Margin & Padding Alignment for All Different Views in Android using XML code in Linear Layout Views.
<?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:contentDescription="@string/app_name"
    android:orientation="vertical"
    tools:context=".MainActivity"

    android:paddingBottom="20dp"
    android:layout_margin="20dp">

</LinearLayout>

NB: 
(i) XML comment line is represented by this symbol <!--     --> but appllied for complete block of statements not for partial lines of code.
(ii) Write the XML codes/program for android design development in 'activity_main.xml' file.
(iii) Remove the comment message completely when execute the program.

Relative Layout Views

Constraint Layout Views

Loading

Categories: Android

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.