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.
<com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:hint="@string/email" android:textColorHint="@color/blueBackground" app:boxBackgroundColor="@color/input_background" app:boxCornerRadiusBottomEnd="20dp" app:boxCornerRadiusBottomStart="20dp" app:boxCornerRadiusTopEnd="20dp" app:boxCornerRadiusTopStart="20dp" app:endIconMode="clear_text" app:endIconTint="@color/blueBackground" app:hintTextColor="@color/blueBackground"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/blueBackground" android:textSize="18sp" android:layout_margin="8dp" /> </com.google.android.material.textfield.TextInputLayout>
I have tried android:background="@null"
and
<item name="colorControlNormal">@android:color/transparent</item> <item name="colorControlActivated">@android:color/transparent</item>
But it is not working.
in the TextInputLayout, set app:boxStrokeWidth="0dp" in the TextInputEditText, set app:boxBackgroundColor="@color/white" . it worked for me when my background is white.
There is a really practical and easy way to remove underline for a text. And that is: textview. setPaintFlags(View. INVISIBLE);
TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.
If you want to use the filled box then below code perfectly work for me.
app:boxStrokeWidth="0dp" app:boxStrokeWidthFocused="0dp"
add above lines in the input layout.
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
:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@android:color/transparent" android:state_pressed="true" android:state_focused="true" android:state_selected="true" android:state_checkable="true" android:state_checked="true" android:state_enabled="true" android:state_window_focused="true" /> </selector>
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 <item name="colorControl*">@android:color/transparent</item>
.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With