我有一个ListView,其中的项由RelativeLayout组成。这是列表项的相关XML:
<?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="wrap_content">
<TextView
android:id="@+id/xx"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/xx" />
<TextView
android:id="@+id/tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/xx"
android:layout_below="@id/title" />
<TextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tag"
android:layout_below="@id/title" />
</RelativeLayout>
在Android 2.1上(在Nexus One上测试),这显示了期望的行为:Android 1.5 http://img42.imageshack.us/img42/7668/85324076.png 然而,在Android 1.5上(在HTC Hero上测试),它显示如下:Android 1.5 http://img257.imageshack.us/img257/2849/72229324.png [编辑] 在1.6(模拟器)上,它也像预期的那样工作。
左上角的小灰线是第一张图片中显示为“xx”的内容,因此应该垂直居中。据我所见,XML规定了这一点,但由于某种原因,1.5忽略了它。
为什么会这样呢?我找不到有关这种差异的任何信息,我一直在尝试使用layout_center、center、alignParent*的任意组合,但都无济于事...
能否有人解释一下这是为什么?谢谢!