问题描述
我有以下XML-
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/group_task_root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/list_selector_background"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/group_task_image"
android:layout_gravity="center"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/group_task_done_indicator"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginStart="14dp"
android:src="@drawable/done"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="14dp"
android:layout_marginEnd="4dp"
android:orientation="vertical">
<TextView
android:id="@+id/group_task_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textDirection="locale"
android:textAlignment="gravity"
android:textSize="18sp"
tools:text="Task's very long title" />
</LinearLayout>
</LinearLayout>
</layout>
对于这种特定的XML,我需要同时支持RTL和LTR。
我面临的问题是这样的-
如您所见,我有很好的RTL文本,但是如果我换行到新行并只写数字而不跟随RTL文本,它将显示在LTR。
对此有适当的解决方法吗?
解决方法
您应该将android:gravity="right"
添加到TextView
我希望为您工作:)