views:

72

answers:

1

Hi all,

Am currently writing an App for Android and in one of the layouts I have a users name and beside it a couple of tags.

If both the users name and the tags are short enough, they fit neatly into one line. However, when either of the two are longer I want the name to stay fixed to the left, and the tags to drop to a line below and align to the right.

Currently I have the following code:

    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/name"
        android:textColor="#000000"
        android:singleLine="true"
        android:textAppearance="?android:attr/textAppearanceSmall" />
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:singleLine="true"
        android:id="@+id/tags"
        android:textColor="#000000"
        android:layout_toRightOf="@+id/name"
        android:layout_alignTop="@+id/name"
        android:textAppearance="?android:attr/textAppearanceSmall" />

This just simply displays both on one line. I presume I'll need to do the text wrapping in the java or is there a neat XML solution?

Thanks for any comments.

A: 

AFAIK, there is no XML solution for this problem.

You need to calculate the size of the name and then adjust the tag on the new line or keep it at same line.

Karan