Reputation: 1060
I have an ImageView aligned to the parent right in a relativeLayout.
Here is my layout:
<RelativeLayout android:id="@+id/row" android:background="@null" style="@style/ListRow"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:textStyle="bold" android:textColor="@color/primary_text" android:text="Username" android:gravity="center_vertical" android:id="@+id/username" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_toLeftOf="@id/avatar" />
<LinearLayout android:gravity="center_vertical" android:id="@+id/time_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@id/username" android:layout_alignBottom="@id/username" android:layout_alignParentLeft="true">
<TextView android:textSize="@dimen/font_size_small" android:text="12:00AM" android:textColor="@color/secondary_text" android:gravity="center_vertical" android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<RelativeLayout android:id="@+id/avatar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5.0dip" android:layout_alignParentRight="true">
<ImageView android:id="@+id/picture" android:src="@drawable/ic_launcher" android:layout_width="48.0dip" android:layout_height="48.0dip" android:scaleType="center" android:adjustViewBounds="true" />
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" />
</RelativeLayout>
<TextView android:textSize="@dimen/font_size_small" android:text="aslkndalskndlaksndlaskndlaksnlansldnaslkndalsdnaslkdnls" android:textColor="@color/primary_text" android:id="@+id/body" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/avatar" android:layout_below="@id/username" android:lineSpacingMultiplier="1.2" />
</RelativeLayout>
Here is what it looks like:
When starting a new line of text I want the text to align on to the right instead of the left. I have photoshopped what I want. Here is what I want:
Anyone know how I should modify my layout to where it does this? Thanks!
Upvotes: 0
Views: 189
Reputation: 189
You are missing the android:gravity="right"
element from your TextView
Body. It should go like
<TextView android:gravity="right"...
That simply makes the text originate on the right side of the TextView
Upvotes: 1
Reputation: 6335
Just add one more property in your TextView body
.
android:gravity="right"
Upvotes: 3