tags:

views:

167

answers:

1

Hi

I am trying to layout 1 textview (upText) left aligned and 1 textview (downText) and an image view (image) both on the same line and right aligned.

how can I do that? I tried that, but both 'textview' and image view at left aligned.

        <TextView
            android:id="@+id/uptext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="left"/>
        <TextView
            android:id="@+id/downtext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:gravity="right|bottom"/>
        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="right|bottom"/>
    </LinearLayout>
+1  A: 

Don't use a LinearLayout. Use a RelativeLayout, with

  • your first TextView set with android:layout_alignParentLeft="true"
  • your second TextView set with android:layout_alignParentBottom="true" and android:layout_alignParentRight="true"
  • something similar for your ImageView, which presently looks like it is going to overlap the second TextView
CommonsWare
Thank you. How can I make it so that both second TextView and ImageView are layout side-by-side at the bottom and right aligned of the parent LinearLayout?
michael
The one that goes all the way in the lower right ("Widget A") should have `android:layout_alignParentBottom="true"` and `android:layout_alignParentRight="true"`. The other one ("Widget B") should have `android:layout_alignParentBottom="true"` and `android:layout_toLeftOf="..."`, where `"..."` is the `android:id` of the Widget A.
CommonsWare