效果圖
-
一般做出來的效果
-
預期效果圖(差別在第二張)
預期效果: 文字單行居右對齊,多行居左對齊.
實現方案
- 讓目標文本控件內居左對齊
- 在目標控件外圍套一層相對佈局,佔滿橫向空間,讓文本控件在相對佈局中居右顯示 .
<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>