TableLayout是由列(row)和行(column)所組成的,而TableLayout的每一列是由<TableRow>所構成,至於每個列中的行可以由各種元件所構成。

layout11.jpg   

小試身手小範例:

<?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 android:layout_marginTop ="40sp">

        <Button

        android:layout_column="0"

        android:text="Row01 Column01"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginLeft="10px"

        />

        <Button

        android:layout_column="1"

        android:text="Row01 Column02"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginLeft="30px"

        />

    </TableRow>

    <TableRow android:layout_marginTop ="40sp">

        <TextView

        android:layout_column="0"

        android:text="TextView\nRow02 Column01"

        android:layout_marginLeft="20px"

        />

        <TextView

        android:layout_column="1"

        android:text="TextView\nRow02 Column02"

        android:layout_marginLeft="35px"

        />

    </TableRow>

    <TableRow android:layout_marginTop ="40sp">

        <EditText

        android:layout_column="0"

        android:text="Row03\nColumn01"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginLeft="5px"

        />

        <EditText

        android:layout_column="1"

        android:text="Row03\nColumn02"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginLeft="30px"

        />

    </TableRow>

</TableLayout>

layout12.jpg  


 

arrow
arrow

    S 發表在 痞客邦 留言(0) 人氣()