2010년 4월 11일 일요일

Android base layout 1

1) Total Project configration
2) Indicate setContentView from Main.java
package kr.mobileplace.lecture;

import android.app.Activity;
import android.os.Bundle;

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myactivity);
    }
}

3) Setting Layout : /MobilePlace Lecture/res/layout/myactivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="#FF880000"
    />
<ImageView
android:src="@drawable/icon"
android:scaleType="center"
android:layout_width="0dp"
    android:layout_height="fill_parent"  
    android:layout_weight="2"
    android:background="#FF008800"
/>
<TextView  
    android:layout_width="0dp"
    android:layout_height="fill_parent"  
    android:layout_weight="1"
    android:background="#FF000088"
    />
</LinearLayout>

4) Result Image

Reference http://www.androidpub.com/

댓글 없음:

댓글 쓰기