Computer scienceMobileAndroidUser InterfaceUI componentsContainers

LinearLayout in Action

Vertical alignment

Report a typo

The text below is in a mess! Fix it by disabling text-specific vertical positioning.

Two TextViews with different sizes aligned by baseline

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ____________________________________
    android:padding="8dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="42sp"
        android:text="Welcome!" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="26sp"
        android:layout_marginLeft="16dp"
        android:text="Make yourself at home!" />

</LinearLayout>
Enter a short text
___

Create a free account to access the full topic