我在我的應用中有兩個ImageView
s,一個TextView
和一個Gallery
,並且希望我的佈局如下所示。使用TableLayout和圖庫在Android中設計佈局
............................................-.
<ImageView>| <TextView> |<ImageView>|
..............................................
| |
| Gallery |
| |
|............................................|
我有一個表的佈局和幾乎拿到屈尊如上所示不同之處在於當文本長度小的ImageView
在屏幕的右端保持移動。我希望屏幕左側和右側的ImageView
的位置固定,而不考慮文本的大小。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TableRow>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageL"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="30px"
android:minWidth="30px" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:paddingLeft="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:layout_gravity="center"
android:minHeight="30px"
android:minWidth="30px" />
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageR"
android:paddingLeft="10px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="30px"
android:minWidth="30px" />
</TableRow>
</TableLayout>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
謝謝。有效。 – Vinoth 2011-02-15 14:46:24