我有一个 ListView,其中包含由 RelativeLayouts 组成的项目。这是列表项中的相关 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* 的任何组合,但无济于事......
任何人都可以对此有所了解吗?谢谢!