Thanks for all of your help.
I found that I have some misunderstanding about android:layout_weight. I don't know why, but it seems conflict with the explation in Tutorial: Notepad Exercise 2.
If the first one has a layout_weight of 1 and the second has a layout_weight of 2, then one third of the remaining space will be given to the first, and two thirds to the second (because we claim the second one is more important).
In the fact, It takes larger screen space when the I assign a smaller value.
So, this is the XML code doing what I said before.
Using xml Syntax Highlighting
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/actionArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="300"
android:orientation="horizontal">
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="@drawable/maid" />
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="vertical">
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Dialer" />
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Contacts" />
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Applications" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/messageArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to Android Phone." />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Meow..." />
</LinearLayout>
</LinearLayout>
Parsed in 0.004 seconds, using
GeSHi 1.0.8.4
It works fine on both landscape of device except that I don't know why I have to assign a very large value of android:layout_weight in the LinearLayout with id actionArea, or the second TextView(Meow...) will missing when the device placed horizontally.
Here is some screenshot.
android:layout_weight="300" works on both.
http://picasaweb.google.com.tw/brianhsu ... 3613342114
http://picasaweb.google.com.tw/brianhsu ... 1347922322
android:layout_weight="1" works only when the device is vertically placed.
http://picasaweb.google.com.tw/brianhsu ... 8655340514
http://picasaweb.google.com.tw/brianhsu ... 4578579346
Finally, after I think about it more carefully, I found that since I'm using TextView as a message area, a better way might be assign a fixed height for it.
Because this will ensuere that there is always a sufficient space to put the text on the screen no matter what device configuration used by the user.
So, there is the final version of my UI XML code and screenshot, and it works perfectly for me.
http://picasaweb.google.com.tw/brianhsu ... 9983968850
http://picasaweb.google.com.tw/brianhsu ... 6842311266
Using xml Syntax Highlighting
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="@drawable/maid" />
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="vertical">
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Dialer" />
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Contacts" />
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Applications" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="100px"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to Android Phone." />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Meow..." />
</LinearLayout>
</LinearLayout>
Parsed in 0.003 seconds, using
GeSHi 1.0.8.4