我有問題讓我的一些視圖對齊在我的列表視圖中使用的相對佈局。爲什麼我的一些視圖在我的相對佈局的底部沒有正確對齊?
下面是Eclipse中的佈局構建一個截圖,這是我認爲它應該是這樣的:
alt text http://janusz.de/~janusz/eclipse.png
下一個圖像是從仿真器。現在TestTestTest視圖位於頂部,涵蓋了Textviews的名稱和距離。
alt text http://janusz.de/~janusz/emulator.png
這是我的佈局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="4dip">
<ImageView android:id="@+id/logo" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:adjustViewBounds="true"
android:scaleType="centerInside" android:src="@drawable/icon"
android:layout_centerVertical="true" android:layout_alignParentLeft="true"
android:background="@color/green" />
<TextView android:id="@+id/distance" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Distance"
android:layout_alignParentRight="true" android:layout_alignParentTop="true"
android:paddingRight="4dip" android:background="#000000" />
<TextView android:id="@+id/name" android:layout_width="fill_parent"
style="@style/ListHeadText" android:layout_height="wrap_content"
android:text="Name"
android:layout_alignTop="@id/distance" android:layout_toRightOf="@id/logo"
android:layout_toLeftOf="@id/distance" android:gravity="clip_horizontal"
android:lines="1" android:paddingLeft="4dip" android:background="@color/red" />
<TextView android:id="@+id/number" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Number"
android:paddingRight="4dip" android:layout_alignRight="@id/distance"
android:background="@color/darkred" android:layout_below="@id/distance" />
<TextView android:id="@+id/subcategory" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Subcategory"
android:paddingLeft="4dip" android:layout_alignLeft="@id/name"
android:lines="1" android:gravity="clip_horizontal"
android:layout_below="@id/distance" android:background="@color/green" />
<TextView android:id="@+id/test" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="TestTestTest"
android:paddingLeft="4dip"
android:layout_alignParentBottom="true" android:gravity="bottom"
android:background="@color/red" />
不應該align_parent_bottom把視圖在列表中的單元格的底部?
更改爲嵌套的線性佈局。 – Janusz 2010-03-26 08:17:43