Commit ef919e8
Use EditText's background for the filled text field and fix underline flakiness.
Use the EditText's background for the filled box text field and a MaterialShapeDrawable drawn to the canvas for the underline. This allows for many improvements to the filled text field.
This commit:
- Fixes the underline flakiness, where the underline used to not meet the edges until drawableStateChanged() was called after a layout pass (because TextInputLayout was attempting to use EditText's pre-existing underline, and the bounds of that Drawable weren't known in order to modify them until after drawableStateChanged())
- Removes the hard-coded box offset since it was only necessary when trying to use EditText's background drawable
- Brings the expanded label/hint a bit closer to the vertical center. Any more than this will require changing the bounds set on the expanded hint text and create misalignment between the expanded hint and any compound drawable that might be set
Specs: https://material.io/design/components/text-fields.html#spec
There is a possible alternative to drawing the underline manually: including the underline as part of the EditText's background. I investigated this option and rejected it, since it would require a re-architecture of the way TextInputLayout handles the box logic and many layers of box drawable nesting. It is much more straightforward and performant to draw the underline directly to the canvas than to convert the boxBackground to {LayerDrawable{MaterialShapeDrawable,{InsetDrawable{MaterialShapeDrawable}}}}.
This commit should only change the visuals of the filled text field; the outline text field should be visually untouched.
PiperOrigin-RevId: 2312469201 parent 9c4bed6 commit ef919e8
File tree
6 files changed
+193
-184
lines changed- docs/components
- lib/java/com/google/android/material/textfield
- res
- color
- values
6 files changed
+193
-184
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
| |||
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
91 | | - | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
0 commit comments