|
201 | 201 | * developer guidance</a> and <a href="https://material.io/components/text-fields/overview">design
|
202 | 202 | * guidelines</a>.
|
203 | 203 | */
|
204 |
| -public class TextInputLayout extends LinearLayout implements OnGlobalLayoutListener { |
| 204 | +public class TextInputLayout extends LinearLayout { |
205 | 205 |
|
206 | 206 | private static final String TAG = "TextInputLayout";
|
207 | 207 |
|
@@ -461,8 +461,6 @@ public interface OnEndIconChangedListener {
|
461 | 461 |
|
462 | 462 | private boolean restoringSavedState;
|
463 | 463 |
|
464 |
| - private boolean globalLayoutListenerAdded = false; |
465 |
| - |
466 | 464 | public TextInputLayout(@NonNull Context context) {
|
467 | 465 | this(context, null);
|
468 | 466 | }
|
@@ -729,17 +727,6 @@ public TextInputLayout(@NonNull Context context, @Nullable AttributeSet attrs, i
|
729 | 727 | setHelperText(helperText);
|
730 | 728 | }
|
731 | 729 |
|
732 |
| - @Override |
733 |
| - public void onGlobalLayout() { |
734 |
| - endLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); |
735 |
| - globalLayoutListenerAdded = false; |
736 |
| - boolean updatedHeight = updateEditTextHeightBasedOnIcon(); |
737 |
| - boolean updatedIcon = updateDummyDrawables(); |
738 |
| - if (updatedHeight || updatedIcon) { |
739 |
| - editText.post(() -> editText.requestLayout()); |
740 |
| - } |
741 |
| - } |
742 |
| - |
743 | 730 | @Override
|
744 | 731 | public void addView(
|
745 | 732 | @NonNull View child, int index, @NonNull final ViewGroup.LayoutParams params) {
|
@@ -1605,7 +1592,6 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
1605 | 1592 | startLayout.bringToFront();
|
1606 | 1593 | endLayout.bringToFront();
|
1607 | 1594 | dispatchOnEditTextAttached();
|
1608 |
| - endLayout.updateSuffixTextViewPadding(); |
1609 | 1595 |
|
1610 | 1596 | // Only call setEnabled on the edit text if the layout is disabled, to prevent reenabling an
|
1611 | 1597 | // already disabled edit text.
|
@@ -3308,12 +3294,13 @@ public void onRtlPropertiesChanged(int layoutDirection) {
|
3308 | 3294 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
3309 | 3295 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
3310 | 3296 |
|
3311 |
| - if (!globalLayoutListenerAdded) { |
3312 |
| - endLayout.getViewTreeObserver().addOnGlobalLayoutListener(this); |
3313 |
| - globalLayoutListenerAdded = true; |
| 3297 | + boolean updatedHeight = updateEditTextHeightBasedOnIcon(); |
| 3298 | + boolean updatedIcon = updateDummyDrawables(); |
| 3299 | + if (updatedHeight || updatedIcon) { |
| 3300 | + editText.post(() -> editText.requestLayout()); |
3314 | 3301 | }
|
| 3302 | + |
3315 | 3303 | updatePlaceholderMeasurementsBasedOnEditText();
|
3316 |
| - endLayout.updateSuffixTextViewPadding(); |
3317 | 3304 |
|
3318 | 3305 | if (!isHintTextSingleLine()) {
|
3319 | 3306 | updateCollapsingTextDimens(
|
|
0 commit comments