How do I position the cursor on the right in EditText

前端 未结 5 717
我在风中等你
我在风中等你 2020-12-30 01:58

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 ty

相关标签:
5条回答
  • 2020-12-30 02:14

    I have the same problem and I am able to fix this by setting android:textDirection in my EditText. e.g

    android:textDirection="inherit"
    

    you can change the value of textDirection as per your requirement. I have taken it as inherit because user are able to change the language with in app. So if user has selected language like english or hindi then it will start typing from left-to-right direction, but if user has selected language like urdu then it will start typing right-to-left direction.

    For this your app minimum API level should be 17.

    0 讨论(0)
  • 2020-12-30 02:23

    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.

    0 讨论(0)
  • 2020-12-30 02:29

    Starting from API Level>=17

    We can use android:layoutDirection in edit text. Also android:gravity="end" should also works.

    0 讨论(0)
  • 2020-12-30 02:34

    IMHO, android:gravity = right only makes the text jusified to the right. But what you want cannot be done with this. You can call a ontouch event in the textbox and add the new character to the right of the current text and display it again.....

    0 讨论(0)
  • 2020-12-30 02:35

    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

    0 讨论(0)
提交回复
热议问题