Table layout demo : TableLayout « UI « Android






Table layout demo

  

package app.test;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class Test extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);;
    setContentView(R.layout.main);

  }
}

//main.xml

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:stretchColumns="1">

  <TableRow>
    <TextView android:text="UserName:" android:textStyle="bold"
      android:gravity="right" android:padding="3dip" />

    <EditText android:id="@+id/username" android:padding="3dip"
      android:scrollHorizontally="true" />
  </TableRow>

  <TableRow>
    <TextView android:text="Password:" android:textStyle="bold"
      android:gravity="right" android:padding="3dip" />

    <EditText android:id="@+id/password" android:password="true"
      android:padding="3dip" android:scrollHorizontally="true" />
  </TableRow>

  <TableRow android:gravity="right">

    <Button android:id="@+id/cancel"
      android:text="Cancel" />

    <Button android:id="@+id/login"
      android:text="Login" />
  </TableRow>
</TableLayout>

   
    
  








Related examples in the same category

1.Switch to a TableLayout
2.Using TableLayout and TableRow to display color
3.Using TableLayout to create input form
4.TableLayout stretchColumns
5.TableLayout and TableRow
6.TableLayout and padding
7.gravity setting inside a TableLayout
8.Code based TableLayout
9.Adding view to TableLayout
10.Shrink a TableLayout
11.Stretch some columns
12.Horizontally centers the content of the cell