方向问题在数字文本英语到阿拉伯语

Direction issue In Numeric text English to Arabic

我正在开发支持阿拉伯语英语语言

的android应用程序

对于阿拉伯语,我遵循以下步骤:

  • Android Studio > Refactor > Add RTL support where possible…
  • 2nd I'll paste this line in manifest.xml : android:supportsRtl="true"

  • I was changed layout property Left and Right with Start and End

哇,我很高兴在这个变化之后,因为当我 select 阿拉伯语 一些设计语言将要 LTR 但是当我测试我的应用程序时,我发现了一些问题。

例如见下图:

当我设置 RTL 时 您可以看到生日 (15/05/1994) 显示为 LTR,所有文本显示为 RTL(DOB,Gender,City).

这里有一个问题,生日显示为 'LTR' 然后 WHY 其他 EditText 不会 RTL.

在这里你可以看到我的代码:

<RelativeLayout
    android:layout_height="wrap_content"
    android:layout_marginEnd="@dimen/_15sdp"
    android:layout_marginStart="@dimen/_15sdp"
    android:layout_marginTop="@dimen/_12sdp"
    android:layout_width="match_parent">

    <TextView
        android:id="@+id/tv_age"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/_5sdp"
        android:layout_width="wrap_content"
        android:text="@string/dob"
        android:textColor="@color/color_gray"
        android:textSize="@dimen/normal_input_text_size" />

    <EditText
        android:background="@null"
        android:focusable="false"
        android:gravity="end"
        android:id="@+id/edit_dob"
        android:layout_alignParentEnd="true"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/_10sdp"
        android:layout_toEndOf="@+id/tv_age"
        android:layout_width="wrap_content"
        android:singleLine="true"
        android:text="15/05/1994"
        android:textSize="@dimen/normal_input_text_size" />
</RelativeLayout><include layout="@layout/half_view" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_12sdp"
android:layout_marginStart="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_15sdp"
android:gravity="center_vertical">

<TextView
    android:id="@+id/tv_gender"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/gender"
    android:layout_centerVertical="true"
    android:textSize="@dimen/normal_input_text_size"
    android:textColor="@color/color_gray"
    android:layout_marginStart="@dimen/_5sdp" />

<EditText
    android:id="@+id/edit_gender"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toEndOf="@+id/tv_gender"
    android:layout_marginStart="@dimen/_10sdp"
    android:layout_alignParentEnd="true"
    android:gravity="end"
    android:text="Male"
    android:focusable="false"
    android:textSize="@dimen/normal_input_text_size"
    android:background="@null"
    android:singleLine="true" />
</RelativeLayout><include layout="@layout/half_view" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_12sdp"
android:layout_marginStart="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_15sdp"
android:gravity="center_vertical">

<TextView
    android:id="@+id/tv_city"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/city"
    android:layout_centerVertical="true"
    android:textSize="@dimen/normal_input_text_size"
    android:textColor="@color/color_gray"
    android:layout_marginStart="@dimen/_5sdp" />

<EditText
    android:id="@+id/edit_city"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toEndOf="@+id/tv_city"
    android:layout_marginStart="@dimen/_10sdp"
    android:layout_alignParentEnd="true"
    android:gravity="end"
    android:focusable="false"
    android:text="Patan"
    android:textSize="@dimen/normal_input_text_size"
    android:background="@null"
    android:singleLine="true" />
</RelativeLayout>

试试这个。

在 RTL 中,当您将文本设置为数字时,就会发生这种情况。

LayoutDirection 属性 添加自 API 19 请检查 Reference

将下面 属性 添加到 Edittext。

android:layoutDirection="ltr"

RTL 屏幕截图

LTR 截图

有关详细信息,请查看此 reference For RTL support