Remove underline from TextInputEditText

后端 未结 13 2299
我寻月下人不归
我寻月下人不归 2021-01-04 01:10

I have an android screen which takes email from the user. Below is the snippet of the code, I want to remove the underline which appears below the text.

<         


        
13条回答
  •  忘掉有多难
    2021-01-04 01:41

    It looks like the Material Components library draws its own underline using app:boxStrokeColor. This attribute is a ColorStateList, so you have to create a color state list resource in which all states' colors are set to transparent. So basically you want to create a new file res/color/filename.xml:

    
    
        
    
    

    and set the app:boxStrokeColor attribute to @color/filename.

    However, this left me with a black underline which still doesn't respond to android:background=@null or @android:color/transparent.


    TL;DR

    Quickfix: if you set the TextInputLayout outlined using style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox", the box looks almost the same, but the underline is gone. In order to remove the stroke just set the app:boxStrokeColor attribute to @null.

提交回复
热议问题