Disable/Remove Text Select Handle from EditText in Android

杀马特。学长 韩版系。学妹 提交于 2019-12-05 23:54:08

问题


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

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


回答1:


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"



回答2:


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.



来源:https://stackoverflow.com/questions/22745986/disable-remove-text-select-handle-from-edittext-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!