Reputation: 11
I am currently trying to hide the underline of a TextInputEditText
when it is disabled. Here is how it looks with the current implementation. I want this same look, but without the underline. Here is the current XML:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:theme="@style/ProfileDetail.TextInputLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_background_profile_item"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="?textAppearanceBody2"
android:enabled="false"
tools:text="Jimmy" />
</com.google.android.material.textfield.TextInputLayout>
The custom style:
<style name="ProfileDetail.TextInputLayout" parent="Widget.Design.TextInputLayout">
<item name="colorControlNormal">@color/white</item>
</style>
What I have tried so far:
TextInputLayout
to a custom style with defined colorControlNormalTextInputEditText
and/or TextInputLayout
to be a solid color drawableMost solutions online suggest using custom styles and setting colorControlNormal but that doesn't seem to do the trick for me. Thanks in advance
Upvotes: 0
Views: 1450
Reputation: 364391
You can use:
<com.google.android.material.textfield.TextInputLayout
app:boxStrokeWidthFocused="0dp"
app:boxStrokeWidth="0dp">
Upvotes: 1
Reputation: 3756
It goes away if you set the background colour to transparent:
yourEditText.setBackground(getResources().getDrawable(R.color.transparent));
where:
<color name="transparent">#00000000</color>
EDIT: After Gabriele's comment I checked again in my project and I can verify that the above solution works for me, as long as I change the background on the TextInputEditText view directly and not through the TextInputLayout. I think the idea is that the colour replaces the background drawable that includes the underline, and since the colour is transparent the view blends with the background.
EDIT 2: Also what seems to work for me if you want to edit the containing layout instead is: mTextInputLayout.setBoxBackgroundMode(TextInputLayout.BOX_BACKGROUND_NONE);
Upvotes: 0