6

I'd like to set an EditText to be LTR at all times, how do I do that? android:textDirection does seem to be the answer, i cant get the project to compile with that directive

Aviran
  • 5,160
  • 7
  • 44
  • 76

4 Answers4

5

use gravity for the editText

android:gravity="right"
JafarKhQ
  • 8,676
  • 3
  • 35
  • 45
  • 1
    I think OP means LTR as in Arabic language, not as aligned to the right. – Vincent Mimoun-Prat Oct 06 '12 at 20:49
  • but when you aligned the arabic text to right its will appear correctly. im an arabic developer – JafarKhQ Oct 06 '12 at 20:57
  • 1
    aligning to the right would work if I wanted RTL text. what I need is LTR directional text. a text that's aligned to the left and in case the chars "aa bb" are inserted the Edit text the text should display "aa bb" and not "bb aa" which is the case when using an RTL language (Hebrew in my case). – Aviran Oct 07 '12 at 05:39
1

Adding \u202D (LTR OVERRIDE) to the beginning of the string does the trick

Aviran
  • 5,160
  • 7
  • 44
  • 76
0

use direction for the editText

android:textDirection="ltr"
0

Add these to your EditText:

android:gravity="left"
android:textDirection="ltr"

Note: android:textDirection requires API level 17

Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
Kaaveh Mohamedi
  • 1,399
  • 1
  • 15
  • 36