This question already has an answer here:
How can i set the cursor position in android edit text? I have an edit text and on create i want to set the cursor to some times in the end some times in the middle of the text, what can i do?
my edit text is as follows:
android:id="@+id/editText11"
android:layout_width="wrap_content"
android:layout_height="200sp"
android:layout_above="@+id/horizontalScrollView1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="top"
android:background="#00000000"
android:inputType="textMultiLine"
android:singleLine="true"
You can achieve this by using :
this will put the cursor position in the end. otherwise you can get the text in a string and check the text position where you want to put the cursor and do it like this
and then
or
Try this
Hope it will help you.
Position at the start
Position at the end
Position at the middle