EditText remove black underline while typing

2019-07-04 03:26发布

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条回答
Explosion°爆炸
2楼-- · 2019-07-04 03:50

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.

查看更多
登录 后发表回答