Android GridLayout
GridLayout
GridLayout
                  was introduced with Android 4.0. This layout allows you to organize a
                  view into a Grid. GridLayout
                  separates its drawing area into: rows,
                  columns, and cells.
                  
               You can specify how many columns you want for define for each
View
                  in which row and column it should be placed and how many columns and
                  rows it should use. If not specified
                  GridLayout
                  uses defaults, e.g. one column, one row and the position of
                  a
                  View
                  depends on the order of the declaration of the
                  Views.
                  
               The following layout file defines a layout using
GridLayout.
                  
               <?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/GridLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:columnCount="4" android:useDefaultMargins="true" > <TextView android:layout_column="0" android:layout_columnSpan="3" android:layout_gravity="center_horizontal" android:layout_marginTop="40dp" android:layout_row="0" android:text="User Credentials" android:textSize="32dip" /> <TextView android:layout_column="0" android:layout_gravity="right" android:layout_row="1" android:text="User Name: " > </TextView> <EditText android:id="@+id/input1" android:layout_column="1" android:layout_columnSpan="2" android:layout_row="1" android:ems="10" /> <TextView android:layout_column="0" android:layout_gravity="right" android:layout_row="2" android:text="Password: " > </TextView> <EditText android:id="@+id/input1" android:layout_column="1" android:layout_columnSpan="2" android:layout_row="2" android:ems="8" /> <Button android:id="@+id/button1" android:layout_column="2" android:layout_row="3" android:text="Login" /> </GridLayout>
This creates a user interface similar to the following screenshot.
Comments
Post a Comment