Viswas Kg
Viswas Kg

Reputation: 245

RTL EditText broken pointer issue in Android

In rtl layout, edittext pointer gets broken in android devices.

I have an application which supports English and Arabic languages. In that the edit text fields with input type number is having this issue mainly. While entering numbers in edit text field, the pointer will break into two halves as shown in the image.

This is the xml code of the edittext.

    <EditText
            android:id="@+id/et_budget"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:background="@drawable/white_background_theme_border"
            android:ems="10"
            android:gravity="center"
            android:hint="@string/choose_budget"
            android:inputType="number"
            android:padding="15dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColorHint="@android:color/black" />

pointer break

Have someone experienced this issue. Is there any fix for the same. Thanks in advance.

Upvotes: 3

Views: 2458

Answers (4)

Samet &#214;ZTOPRAK
Samet &#214;ZTOPRAK

Reputation: 3346

android:textDirection="ltr" left to right
android:textDirection="rtl" right to left

It makes text direction to the chosen side. If your input value is Latin characters I highly recommend you ltr (for Arabic). but labels are positioned as its nature (like Arabic right, English left)

Upvotes: 0

Kavita Patil
Kavita Patil

Reputation: 1864

Instead of using android:inputType="number" , setting android:inputType="phone" worked in my case. As I just wanted to type number in my edit text.

Following is my EditText from xml :

<EditText
        android:layout_gravity="start"
        android:textAlignment="viewStart"
        android:textDirection="rtl"
        android:gravity="center_vertical"
        android:layout_width="match_parent"
        android:hint="abc"
        android:inputType="phone"
        android:id="@+id/myNumber"
        android:paddingStart="8dp"
        android:paddingLeft="8dp"
        android:background="@android:color/transparent"
        android:textColorHint="#767676"
        android:backgroundTint="@android:color/transparent"
        android:layout_height="fill_parent"
        tools:ignore="RtlCompat" />

Upvotes: 0

jelic98
jelic98

Reputation: 713

Have you tried this

Layout

<EditText>
    ... 
    android:gravity="right"
    android:textDirection="rtl"
</EdiText>

AndroidManifest.xml

<application
    ...
    android:supportsRtl="true">
    ...
</application>

Upvotes: 2

Bishoy Kamel
Bishoy Kamel

Reputation: 2355

simply add this line

 android:layoutDirection="ltr"

Upvotes: 0

Related Questions