Search code examples
androidandroid-layoutmaterial-designandroidxandroid-textinputlayout

How to remove white box from TextInputLayout


Today I have just updated my dependencies of material design

from 1.0.0 to 1.1.0-alpha09

implementation 'com.google.android.material:material:1.1.0-alpha09'

Now i"m getting strange issue in com.google.android.material.textfield.TextInputLayout

Here is my Code

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/emailTextInputLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/_10sdp">

            <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/emailTextInputEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/hint_enter_email"
                    android:imeOptions="actionNext"
                    android:inputType="textEmailAddress"/>
        </com.google.android.material.textfield.TextInputLayout>

after updating the dependencies I'm getting boxed design in my TextInputLayout

Output of above code

enter image description here

if i use implementation 'com.google.android.material:material:1.0.0' I'm getting expected result

enter image description here

Can anybody help me to solve this issue

If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.

UPDATE

I have already tried app:boxBackgroundMode="none" them I'm getting this

output ,

if i use app:boxBackgroundMode="outline" then getting this

output

SOLVED

No need to use boxBackgroundMode

You need to add @style/Widget.Design.TextInputLayout in your TextInputLayout

SAMPLE CODE

        <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/emailTextInputLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/_10sdp"
                style="@style/Widget.Design.TextInputLayout"
                app:errorTextAppearance="@style/error_appearance"
                android:textColorHint="@android:color/white">

            <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:id="@+id/emailTextInputEditText"
                    android:layout_height="wrap_content"
                    android:backgroundTint="@android:color/white"
                    android:gravity="center"
                    android:hint="@string/hint_enter_email"
                    android:imeOptions="actionNext"
                    android:textColorHint="@android:color/white"
                    android:inputType="textEmailAddress"
                    android:textColor="@android:color/white"
                    android:textSize="@dimen/_15ssp"/>
        </com.google.android.material.textfield.TextInputLayout>

OUTPUT enter image description here


Solution

  • To revert back to old style with no filed background but only bottom border, one should use following style:

    <com.google.android.material.textfield.TextInputLayout
               ...
               style="@style/Widget.Design.TextInputLayout"
               ....
               >
    </com.google.android.material.textfield.TextInputLayout>
    

    Using theme Widget.Design.TextInputLayout will generate expected output like below:

    enter image description here