The following code shows how to Create a TableLayout with only one row.
Main layout xml file
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableRow> <TextView android:id="@+id/text_view_1" android:layout_width="150px" android:layout_height="100px" android:background="@android:color/darker_gray" /> <TextView android:id="@+id/text_view_2" android:layout_width="150px" android:layout_height="100px" android:background="@android:color/white" /> </TableRow> </TableLayout>
Main Activity Java code
import android.app.Activity; import android.os.Bundle; /*from w ww .j a v a2 s . c om*/ public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }