Search code examples
androidandroid-edittext

How do I hide of Bubble cursor on EditText?


If you have an EditText, clicking it will show a Bubble Cursor. I show a picture below (using Twitter app as example)...

My question is:

  1. What is this called actually (I think it's not Bubble Cursor definitely)?
  2. How to disabled it from our EditText? (or from our entire Activity/Fragment/App)

enter image description here


Solution

  • It's called text select handle.

    There is a tricky way to hide it: replace with an 0px transparent drawable in your style.xml.

    drawable/zero_px_transparent.xml

     <?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 modify your style.xml:

    <style name="CustomTheme" parent="@android:style/Theme.Holo.Light">
         <item name="android:textSelectHandleLeft">@drawable/zero_px_transparent</item>
         <item name="android:textSelectHandleRight">@drawable/zero_px_transparent</item>
         <item name="android:textSelectHandle">@drawable/zero_px_transparent</item>
    </style>