Android Basics – Learn about the Grid Layout

Introduction

Grid Layout is very useful if you want your App to display elements in Rows and Columns.

This Layout allows you to divide your UI into Rows and Columns similar to HTML tables.

Doing this is pretty simple. Please refer to the Image.

I have recorded a Video to help you understand how to use this Layout.

Some Code Snippets

<GridLayout xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:columnCount=”2″>

<TextView
android:layout_height=”wrap_content”
android:layout_width=”wrap_content”
android:layout_row=”0″
android:layout_column=”0″
android:text=”Email”
android:layout_margin=”5dp”
android:padding=”5dp”
/>

The Source Code is available at : https://github.com/ankur-srivastava/HelloAndroid/blob/master/app/src/main/res/layout/grid_layout.xml