键入时,EditText删除黑色下划线 [英] EditText remove black underline while typing

查看:217
本文介绍了键入时,EditText删除黑色下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的EditText有点问题.

I have bit of an issue in my EditText.

我有一段代码可以检测何时在特定文本上加上下划线(以便可以突出显示下划线图标).这是通过检测UnderlineSpans来实现的.但是,在键入时,当前单词下方会带有下划线,这似乎也使用UnderlineSpans,因此会导致选择下划线图标: https://i.stack.imgur.com/jBloM.jpg

I have a piece of code that detects when a specific piece of text is underlined (so that a underline icon can be highlighted). This is achieved by detecting UnderlineSpans. However when typing there are underlines under the current word, which appears to also use UnderlineSpans, therefore leading the underline icon being selected: https://i.stack.imgur.com/jBloM.jpg

我已经尝试将android:inputType="textNoSuggestions"添加到我的EditText XML中.但是,这似乎禁用了拼写检查,但没有禁用黑色下划线.是否有必要删除此下划线(最好不删除拼写检查),还是我可以检测自己的UnderlineSpans的替代方法?

I've already tried adding android:inputType="textNoSuggestions" to my EditText XML. However this appears to disable spell checking, but not the black underline. Is there anyway to remove this underline (preferably without removing spell checking) or an alternative for me to detect my own UnderlineSpans?

推荐答案

在我的情况下,可以对其进行修复.我创建了一个空的UnderlineSpan类.例如

Managed to fix it in my case. I created an empty UnderlineSpan class. e.g.

public class CustomUnderlineSpan extends UnderlineSpan {
}

然后我在我的跨度设置和检测代码中使用了它.这意味着我所有其他下划线范围现在都在使用此类,因此仅当存在我的自定义下划线范围之一时才选择图标. Android的底线仍然存在,但是在这种情况下,这对我来说不是问题.

I then used this in my span setting and detection code. This meant that all my additional underline spans were now using this class, so the icon was only selected when one of my custom underline spans is present. The underline from Android is still there, but it isn't a problem for me in this case.

这篇关于键入时,EditText删除黑色下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆