How do I position the cursor on the right in EditText

Asaf Pinhassi picture Asaf Pinhassi · Oct 18, 2011 · Viewed 18.1k times · Source

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?

Answer

Poovizhirajan N picture Poovizhirajan N · Dec 5, 2012

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