[英]How to align the text on the right side of a picture?
I have an ImageView aligned to the parent right in a relativeLayout. 我有一个ImageView相对于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! 谢谢!
只需在TextView body
添加一个属性即可。
android:gravity="right"
You are missing the android:gravity="right"
element from your TextView
Body. 您缺少TextView
的android:gravity="right"
元素。 It should go like 它应该像
<TextView android:gravity="right"...
That simply makes the text originate on the right side of the TextView
<TextView android:gravity="right"...
只是使文本起源于TextView
的右侧
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.