How to remove the underline from the EditText field in Android?

后端 未结 10 1129
心在旅途
心在旅途 2020-12-14 14:47

Whenever a word is typed in the EditText box, I always see an underline under the word being typed. But when I press a space after that word I no longer see the underline.

相关标签:
10条回答
  • 2020-12-14 15:01

    There is a function that removes any composing state. I think if you call it after every time a user types, you will not see the underline. I use it after the user finishes typing, to get the drawing cache of the entire textView (which I need without underline). It's

    someTextView.clearComposingText();
    
    0 讨论(0)
  • 2020-12-14 15:02

    Use this from your class, if EditText view is dynamic (created from class file):

    EditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    

    OR include android:inputType="textNoSuggestions" with your EditText in XML.

    0 讨论(0)
  • 2020-12-14 15:03

    android:inputType="textNoSuggestions"

    0 讨论(0)
  • 2020-12-14 15:05

    Read this if you want to keep emojis and textNoSuggestions doesn't work for you.

    textNoSuggestions does not work in every keyboard. inputType="textVisiblePassword" works but it removes emoji's from most keyboards.

    I found that setting inputType="textUri" works and keeps the ability to add emojis.

    0 讨论(0)
  • 2020-12-14 15:06

    You can set the EditText to have a custom transparent drawable or just use android:background="@android:color/transparent".

    0 讨论(0)
  • 2020-12-14 15:07

    The best solution for this is to add on your EditText:

     android:inputType="textMultiLine|textVisiblePassword"
    
    0 讨论(0)
提交回复
热议问题