18

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

Community
  • 1
  • 1
Goku
  • 9,102
  • 8
  • 50
  • 81

5 Answers5

14

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

Jeel Vankhede
  • 11,592
  • 2
  • 28
  • 58
3

Using a material Theme the default style used by the TextInputLayout is @style/Widget.MaterialComponents.TextInputLayout.FilledBox

enter image description here

To obtain something similar just change the background color using the boxBackgroundColor attribute:

  <style name="CustomFilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
    <item name="boxBackgroundColor">@myColor</item>
  </style>

enter image description here

Also use the android:hint="@string/hint_enter_email" in the TextInputLayout not in the TextInputEditText

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Thanks i'm using `style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox" app:boxBackgroundColor="@android:color/transparent"` but getting this [output](https://i.stack.imgur.com/LPYEy.png) – Goku Aug 29 '19 at 06:22
  • And my app this `style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar"` – Goku Aug 29 '19 at 06:24
  • Use the same color of your app background, black in your case. – Gabriele Mariotti Aug 29 '19 at 06:25
  • Sir, i have already tried that check this [output](https://i.stack.imgur.com/YJZlZ.png) – Goku Aug 29 '19 at 06:32
  • @Goku Something strange in your style. You should use boxBackgroundColor with a dark color and hint text white or red. – Gabriele Mariotti Aug 29 '19 at 06:55
1

For me using @style/Widget.Design.TextInputLayout produced undesirable formatting results, specifically alignment issues with the editText box.

I used boxBackgroundMode set to none for awhile, and after updating material design in my project the error icon mentioned started showing. May be a bug (https://issuetracker.google.com/issues/122445449).

For now I'm still setting the boxBackgroundMode to none, and hiding the error icon by setting the color to transparent. This way I keep the material design.

app:boxBackgroundMode="none"
app:errorIconTint="@android:color/transparent"



<com.google.android.material.textfield.TextInputLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="5dp"
        app:boxBackgroundMode="none"
        app:errorIconTint="@android:color/transparent"
        app:hintEnabled="false">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/message_ellipsis"
            android:inputType="textCapSentences|textMultiLine"
            android:paddingTop="10dp" />
    </com.google.android.material.textfield.TextInputLayout>
Goku
  • 9,102
  • 8
  • 50
  • 81
Andrew
  • 619
  • 1
  • 7
  • 10
0

Set this in your TextInputLayout:

app:boxBackgroundMode="none"

Probably you have set boxBackgroundMode to filled or maybe it's set by default. Just add above line, and this should fix the issue.

Arslan Shoukat
  • 432
  • 4
  • 10
0

Same behavior with com.google.android.material:material:1.3.0

Applying transparent background to TextInputEditText does the tricks.

android:background="@android:color/transparent"
user370305
  • 108,599
  • 23
  • 164
  • 151