안드로이드 학습노트--MixLayout

이 프로젝트의 기능은 LinearLayout+TableLayout을 실현하는 것이다
 
다음 코드는MainActivity입니다.java의 코드
package com.example.mixlayout;



import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.widget.TextView;



public class MainActivity extends Activity {



    private TextView firstText; 

    

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

    }

}

 
다음 코드는 activitymain.xml 코드
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/LinearLayout1"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical"

    tools:context="${relativePackage}.${activityClass}" >



    <LinearLayout

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:layout_weight="1"

        android:orientation="horizontal" >



        <TextView

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:layout_weight="1"

            android:background="#aa0000"

            android:gravity="center_horizontal"

            android:text="red" />



        <TextView

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:layout_weight="1"

            android:background="#00aa00"

            android:gravity="center_horizontal"

            android:text="green" />



        <TextView

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:layout_weight="1"

            android:background="#0000aa"

            android:gravity="center_horizontal"

            android:text="blue" />

    </LinearLayout>



    <LinearLayout

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:layout_weight="1"

        android:orientation="horizontal" >



        <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:padding="3dip"

                    android:text="row1_column1" />



                <TextView

                    android:gravity="center_horizontal"

                    android:padding="3dip"

                    android:text="row1_column2" />



                <TextView

                    android:gravity="right"

                    android:padding="3dip"

                    android:text="row1_column3" />

            </TableRow>



            <TableRow>



                <TextView

                    android:padding="3dip"

                    android:text="row2_column1" />



                <TextView

                    android:gravity="center_horizontal"

                    android:padding="3dip"

                    android:text="row2_column2" />



                <TextView

                    android:gravity="right"

                    android:padding="3dip"

                    android:text="row2_column3" />

            </TableRow>

        </TableLayout>

    </LinearLayout>



</LinearLayout>

좋은 웹페이지 즐겨찾기