Android UI Layout

Android layout is used to define the user interface for application design. A layout is a widget and UI controls that will appear on the screen of an Android application

Generally, an application is a combination of view and viewgroup. Android application contains multiple activities. Hence, every application contains multiple user interfaces. 

There are two types of Layout: 

  • View
  • View Group

View: 

A View is defined as the user interface that is used to create UI components such as ImageView, EditText, RadioButton Textview, etc.


View Group:

A ViewGroup acts as a class for layouts and holds other views or view groups to define the layout properties.

 

Type of Android layout


1. Android Constraint Layout: 

Constraintalayout is a viewgroup subclass, specifying the position of layout constraints for every child view.

Example:

<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

2. Android linear layout:  

A linear layout is a view group, used to provide a child view set horizontally or vertically based on the orientation property.

Example:

<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:id="@+id/main"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</LinearLayout>

3. Android Relative layout: 

Relativelayout is a viewgroup used to specify the position of a child view.

Example:

<RelativeLayout 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:id="@+id/main"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
</RelativeLayout>

4. Android Frame Layout: 

Frame layout is a viewgroup, used to specify the position of the child view.

Example:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:id="@+id/main"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</FrameLayout>

5. Android Table Layout: 

Frame layout is a viewgroup, used to specify the position of child view elements in rows and columns.

Example:

<TableLayout 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:id="@+id/main"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</TableLayout>

6. Android Grid view: 

Grid layout is a viewgroup, used to specify the position of the child view display.

Example:

<GridLayout 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:id="@+id/main"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</GridLayout>

Happy Coding.



365Bloggy May 6, 2024
Share this post
Tags
SUBSCRIBE THIS FORM


Archive