How to set cursor position in EditText?

前端 未结 23 1571
广开言路
广开言路 2020-11-28 02:51

There are two EditText,while loading the page a text is set in the first EditText, So now cursor will be in the starting place of EditText, I want

23条回答
  •  鱼传尺愫
    2020-11-28 03:14

    I believe the most simple way to do this is just use padding.

    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.

    For more detail, check this article on my blog: Android: Setting Cursor Starting and Ending Position in EditText Widget

提交回复
热议问题