LinearLayout and Its Important Attributes GG With Examples in Android
LinearLayout and Its Important Attributes GG With Examples in Android
Examples in Android
Read Courses Jobs
LinearLayout is the most basic layout in android studio, that aligns all the children sequentially either
in a horizontal manner or a vertical manner by specifying the android:orientation attribute. If one
applies android:orientation=”vertical” then elements will be arranged one after another in a vertical
manner and If you apply android:orientation=”horizontal” then elements will be arranged one after
another in a horizontal manner.
XML
Attributes Description
This must be a boolean value, either “true” or “false” and prevents the
layout
android:baselineAligned
from aligning its children’s baselines.
Examples
XML
</LinearLayout>
Output UI:
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<!-- Add horizontal in the android:orientation-->
</LinearLayout>
Output UI:
3. How to use layout_weight and weightSum
XML
</LinearLayout>
Output UI:
4. How to use gravity
XML
</LinearLayout>
Output UI:
XML
</LinearLayout>
Output UI: