效果图
-
一般做出来的效果
-
预期效果图(差别在第二张)
预期效果: 文字单行居右对齐,多行居左对齐.
实现方案
- 让目标文本控件内居左对齐
- 在目标控件外围套一层相对布局,占满横向空间,让文本控件在相对布局中居右显示 .
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/selectAddressLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="分类"
android:textColor="#FF333333" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginStart="40dp"
android:text="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
android:textColor="#999999"
tools:ignore="SpUsage" />
</RelativeLayout>
</LinearLayout>