Grid Layout in Android



GridLayout is a layout that divides its view space into rows, columns, and cells. GridLayout places views in it automatically, but it is also possible to define the column and row index to place a view into GridLayout. With the span property of cells, it is possible to make a view span multiple rows or columns. The following code block shows a sample layout file using a GridLayout layout:


 


android:id=\\\"@+id/GridLayout1\\\"


android:layout_width=\\\"match_parent\\\"


android:layout_height=\\\"match_parent\\\"


android:columnCount=\\\"2\\\"


android:orientation=\\\"horizontal\\\" android:rowCount=\\\"2\\\">


<TextView


android:id=\\\"@+id/textView1\\\"


android:text=\\\"Cell 1,1\\\"


android:textAppearance=\\\"?android:attr/textAppearanceLarge\\\" />


<TextView


android:id=\\\"@+id/textView2\\\"


android:text=\\\"Cell 1,2\\\"


android:textAppearance=\\\"?android:attr/textAppearanceLarge\\\" />


<TextView


android:id=\\\"@+id/textView3\\\"


android:text=\\\"Cell 2,1\\\"


android:textAppearance=\\\"?android:attr/textAppearanceLarge\\\" />


<TextView


android:id=\\\"@+id/textView4\\\"


android:text=\\\"Cell 2,2\\\"


android:textAppearance=\\\"?android:attr/textAppearanceLarge\\\" />


 


In GridLayout, you can explicitly define the cell that a view will be placed in by specifying the index of the column and row. If the index is not specified, GridLayout will automatically place the views to the first available position according to the orientation of the GridLayout layout.

Editor: ankita Added on: 2013-02-27 14:16:54 Total View:316







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---