How to achieve vertical alignment in Android Linear Layout?
To achieve vertical alignment in Android linear layout, you can use a LinearLayout layout and set its orientation property to “vertical”. Here is an example code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 3" />
</LinearLayout>
In the above code, the LinearLayout’s orientation property is set to “vertical”, which means its child views will be arranged in a vertical direction. In this example, three TextViews will be arranged vertically from top to bottom.