My application uses RTL language (right to left).
When the EditText
field gets focus, the cursor appears on the left and only when the user starts to type, the cursor (and the RTL text) moves right.
When the user clicks "enter" to start a new line, the cursor moves to the left again.
When I use android:gravity="right"
, the cursor is OK (on the right) but as the user starts to type the text always moves to the the other side (RTL text moves left).
Any ideas how I can align text to the right AND keep the text direction?
Say in your xml's edittext section, add android:paddingLeft="100dp" This will move your start position of cursor 100dp right from left end. Same way, you can use android:paddingRight="100dp" This will move your end position of cursor 100dp left from right end.
setSelection(editText. getText(). length()); This places cursor to end of EditText.
try this android:windowSoftInputMode="adjustResize" in your activity in manifest file.
Its works for me
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ellipsize="end"
android:gravity="right" />
ellipsize
is important
It solves your problem
You might want to look into the native RTL support that was introduced in Android 4.2 Jelly Bean.
http://developer.android.com/about/versions/jelly-bean.html
Android 4.2 introduces full native support for RTL (right-to-left) layouts, including layout mirroring. With native RTL support, you can deliver the same great app experience to all of your users, whether their language uses a script that reads right-to-left or one that reads left-to-right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With