EditText remove black underline while typing

∥☆過路亽.° 提交于 2019-12-10 19:47:03

问题


I have bit of an issue in my EditText.

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

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?


回答1:


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

public class CustomUnderlineSpan extends UnderlineSpan {
}

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.



来源:https://stackoverflow.com/questions/46822580/edittext-remove-black-underline-while-typing

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