How to remove Android auto-suggest underlining in EditText?

☆樱花仙子☆ 提交于 2019-12-06 22:30:23

问题


I'm using an EditText to write some text. Android's auto-suggest underlines the word, until we hit space. Now, if I enter the word without the space, the resulting text has an underline. It's because I use Html.toHtml(view.getText()).

Now, there are a few answers I'll be expecting such as disabling auto-suggestion or using view.getText().toString(), but I need them both. I need the auto-suggestion feature as well as the formatting of the text. An example which solves this problem is the Gmail app. You can write whatever you want in the EditText box and it sends the email without the words being underlined.


回答1:


Use this just before you getText(). This is the most straightforward and the official way.

 edittext.clearComposingText();



回答2:


Do it like this

android:inputType="text|textNoSuggestions"  



回答3:


I just came up with a solution for this. After submitting the text, just hide the keyboard, and the text underline goes away.



来源:https://stackoverflow.com/questions/30992048/how-to-remove-android-auto-suggest-underlining-in-edittext

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