Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable/Remove Text Select Handle from EditText in Android

When user click on EditText the cursor comes up with the Text Select Handle. Text Select Handle can move around to a different position in the field. Text Select Handle is

enter image description here

Is there a way you can remove that so it does not show up?

like image 661
void Avatar asked Mar 30 '14 15:03

void


2 Answers

To resolve this issue i have created an empty image in shape.

 <?xml version="1.0" encoding="UTF-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle" >

 <size
    android:height="0dp"
    android:width="0dp" />

 </shape>

and just use this image in edit text

 android:textSelectHandle="@drawable/your_empty_image"
like image 146
Deepak Goel Avatar answered Oct 30 '22 01:10

Deepak Goel


A great solution was provided by @Deepak Goel, but this approach has one downside. The "Text Select Handle" is disabled permanently for the given EditText.

Another approach is to call clearFocus() and then requestFocus(). It does the work, but it does not seem optimal. If someone dives deeper in the Android sources, he may find a more optimized solution though.

like image 42
Vaios Avatar answered Oct 30 '22 02:10

Vaios