如何在EditText上隐藏Bubble光标?

Ely*_*lye 6 android android-edittext

如果你有EditText,点击它将显示一个气泡光标.我在下面显示一张图片(以Twitter应用程序为例)......

我的问题是:

  1. 实际上这叫什么(我认为它绝对不是Bubble Cursor)?
  2. 如何禁用它EditText?(或来自我们的整个活动/片段/应用程序)

在此输入图像描述

anh*_*nnd 9

它叫做文本选择句柄.

隐藏它有一种棘手的方法:用style.xml中的0px透明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>
Run Code Online (Sandbox Code Playgroud)

并修改你的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>
Run Code Online (Sandbox Code Playgroud)

  • @anhtuannd如果用户点击光标下方的空白区域,则用户可以看到PASTE选项 (2认同)