Hello. I've been fighting for hours now, and still do not understand what I'm missing. Sorry for posting only text, since I cannot attach an image to this post.
I have an activity which uses an XML layout made of a top-level RelativeLayout composed of 3 TextViews (see the XML at the end of the post): - the first one (id=leftText, =green) with a green background is intended to have its left border aligned with the left's of the screen (i.e. on the left) and always visible, i.e. never pushed out of the screen on the far left especially because of the second TextView (with id=centralText) text length. Ideally, this TextView should be centered vertically in its layout. - the third one (id=rightText, =blue) with a blue background is intended to have its right border aligned with the right border of the screen (i.e. on the right) and always be visible and not pushed out of the screen on the far right (same remark as for the first TextView). Ideally, this TextView should be centered vertically in its layout. - the second one (id=centralText, =red) with the red background is intended to be between the first and third TextViews. It contains some lenghty textual contents which spans multiple lines. My problem is that I cannot manage the first (green) and third(blue) TextViews to be centered vertically. I use the android:layout_centerVertical="true" attribute on both views on that purpose, but this does not generate the expected right result: the two TextViews seem to stretch the RelativeLayout height and are aligned to the bottom of this layout. I get: ---------------------------- | | red | | | | red | | | | red | | | -------- | --------- -------- | green | | blue | ---------------------------- If I do not use this layout_centerVertical attribute, I get the expected (which is not what I want): ---------------------------- | green | red | blue | --------- ------- | | red | | | | red | | --------------------------- I use the RelativeLayout because I want the blue (=third) TextView to be on the right and always visible, whatever the length of the red (=second) TextView. Hence, I need to declare it first in the RelativeLayout. It seems that the RelativeLayout drawing does not take properly into account the red TextView height in order to center vertically the blue and green TextViews. I am open to any suggestion to match my requirements and have the following rendering: ---------------------------- | | red | | --------- -------- | green | red | blue | --------- ------- | | red | | ---------------------------- Thank you so much for your time. Regards, Édouard Here is the standalone source code of the XML layout, so that you can reproduce the problem: <?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" android:background="#ff0" > <TextView android:id="@+id/leftText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:text="A left text" android:background="#0f0" /> <TextView android:id="@+id/rightText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:text="A right text" android:background="#00f" /> <TextView android:id="@+id/centralText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/rightText" android:layout_toRightOf="@id/leftText" android:text="Some central very long text which spans multiple lines in order to demonstrate the problem: the green left and the right blue texts should be centered vertically" android:background="#f00" /> </RelativeLayout> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

