1

I'm developing an application that supports arabic and english locales. When the user has the arabic language set on their phone, the edittexts input direction should automatically change from left-to-right to right-to-left. This works for all edittexts except one where the inputType is set to textPassword. If I change the inputType to text, the direction changes properly. Otherwise, it remains left-to-right. Is there any reason this may be happening or any fix for this?

Thank you.

Sammy Jaafar
  • 513
  • 5
  • 21
  • try with this solution from another thread: [Can you make an EditText input from right to left?](http://stackoverflow.com/questions/5083768/can-you-make-an-edittext-input-from-right-to-left) – mfruizs Oct 30 '15 at 08:06
  • Thanks for your reply mfruizs2. I've set the gravity to "start" in xml. That should position the text correctly. The problem is not just that the gravity remains at the left, but the input direction when the user types remains from left-to-right. – Sammy Jaafar Oct 30 '15 at 08:10
  • 3
    See this question: http://stackoverflow.com/questions/17838216/android-rtl-password-fields – Daniel Zolnai Oct 30 '15 at 08:10
  • Thanks Daniel. The post helped me out. – Sammy Jaafar Oct 30 '15 at 08:30

1 Answers1

0

I fixed the same issue as follow:

Put default value for gravity in the xml:

gravity = "left|start"

Then from the code check whether your app run in RTL and if so - change the text direction to RTL:

public static boolean isRTL(Locale locale) {
    final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0));
    return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT ||
            directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
}



if (isRTL())
        mPasswordTV.setTextDirection(View.TEXT_DIRECTION_RTL);
Nativ
  • 3,092
  • 6
  • 38
  • 69