Tutorial on Android Table Layout, Table Layout will explains you to arrange data in row and coloumns.It is same as tbale in html.Syntax also quite similar,you can obseve it in below picture.
Activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="1" android:padding="50dp" android:background="#bdbdbd" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="2" android:padding="50dp" android:background="#eeeeee" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="3" android:padding="50dp" android:background="#999999" /> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="4" android:padding="50dp" android:textColor="#ffffff" android:background="#333333" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="5" android:padding="50dp" android:textColor="#ffffff" android:background="#444444" /> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="6" android:padding="50dp" android:textColor="#ffffff" android:background="#3399ff" /> </TableRow> </TableLayout> </RelativeLayout>
Main Activity.Java
package info.siddhu.tablelayout; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }