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

后端 未结 10 1130
心在旅途
心在旅途 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:13

    accepted answer is not given solution, and some other user given answer but no one given full anser, so that's why i write here working solution.

    If you want to remove underline then just add below code.

    XML

    android:inputType="textNoSuggestions"
    

    Java

    EditText ed;
    ed = findViewById(yourId);
    ed.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    

    If you want to set more than one input type then,

    ed.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    

    May be above information is helpful to others.

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

    try:

    android:inputType= InputTypes.TextVariationVisiblePassword;
    
    0 讨论(0)
  • 2020-12-14 15:19

    You don't have to use any logic to remove the underlines -- just call getText().toString() when you want to use the value. It won't include special formatting or anything.

    0 讨论(0)
  • 2020-12-14 15:20
    <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:imeOptions="actionDone"
            android:inputType="textNoSuggestions"
            android:maxLines="1"
            />
    
    0 讨论(0)
提交回复
热议问题