RelativeLayout differences between 1.5 and 2.1
Posted
by Kilnr
on Stack Overflow
See other posts from Stack Overflow
or by Kilnr
Published on 2010-05-17T15:22:03Z
Indexed on
2010/05/17
15:40 UTC
Read the original article
Hit count: 385
I've got a ListView with items composed of RelativeLayouts. This is the relevant XML from the list items:
<?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>
On Android 2.1 (tested on a Nexus One), this shows the desired behavior:
On Android 1.5 however (tested on a HTC Hero), it shows up like this:
[edit] On 1.6 (emulator), it works as expected as well.
The small grey line on the top left is what shows up in the first pic as "xx", so that should be vertically centered. As far as I can see, the XML dictates this, but for some reason, 1.5 ignores it.
Why is this? I can't find anything about this difference, and I've been brute forcing any combination of layout_center, center, alignParent*, but to no avail...
Can anyone shed some light on this? Thanks!
© Stack Overflow or respective owner