Create a TableLayout with only one row

Description

The following code shows how to Create a TableLayout with only one row.

Example

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  w w  .  j  av a2s .  co  m
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);
    }
}
Create a TableLayout with only one row




















Home »
  Android »
    Android UI »




UI Basics
Action Bar
Animation
Button
Canvas
CheckBox
Clock Date Picker
Dialog
EditText
Event
Fragment
Gesture
GridView
ImageView
Layout
ListView
Map
Menu
Model
OpenGL
ProgressBar
RadioButton
Spinner
Tab
TextView
Thread
Toast
Video
View
WebView