Good luck with that one... i tried but no luck.

If you think about it, it makes sense that this is not 'easy' to do
with the standard controls (like the text view).

The text-view knows about its parent (the rel. layout), not about its
siblings (imageview).
If you center the text-view in the parent, the largest extent of the
text-view is the left-and right border of the parent. The text-view
doesn't know about the imageview and where it exactly is and can not
position itself or its text relative to the image-view borders.

You can also specify instead that the text-view is right-aligned and
is 'to-the-right-of' the imageview and the text inside the text-view
is centered. However, that will put the text off-center, a bit too
much to the right.

I 'solved' it by putting an equal amount of empty space (an empty
View) to the right of the text-view:
  imageview: left aligned, with specific width.
  textview: right-of imageview, left-of emptyview. Text is centered.
  emptyview: right aligned, with same width as imageview.
This solution is not perfect, since the text will never go all the way
to the right. But then, again, this does make some sense, since the
text doesn't go all the way to the left either. If the text would
extend all the way to the right and not all the way to the left, the
text would appear off-center.


On Jul 10, 5:29 pm, Connick <oconn...@gmail.com> wrote:
> I have a relative layout with an imageview aligned to parent left and a
> textview centered horizontally/vertically in the parent. Is there a way I
> can indicate that the textview should not overlap the imageview should the
> text be long enough to fill the parent?
>
> Cheers,
> Stace

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to