본문 바로가기

JAVA/Android

안드로이드 Table(TableRow) 예제 따라하기

- TableRow를 이용해서 화면을 table형식으로 배치 할 수 있다.
- 이 예제를 통해 화면배치를 해보도록 하자. 

-xml 소스
<?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"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="국어     " />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="영어     " />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="수학" />
    </TableRow>

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="88     " />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="92     " />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="76" />
    </TableRow>


</TableLayout> 

-실행 화면