当新句子以数字开头时,RTL文本不是从右开始

问题描述

我有以下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。

我面临的问题是这样的-

enter image description here

如您所见,我有很好的RTL文本,但是如果我换行到新行并只写数字而不跟随RTL文本,它将显示在LTR。

对此有适当的解决方法吗?

解决方法

您应该将android:gravity="right"添加到TextView

我希望为您工作:)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...