Skip to content

Commit 15fa4db

Browse files
pubiqqhunterstich
authored andcommitted
[TextInputLayout] Fix "android:enabled" attribute support
Resolves #2766 Resolves #2769 GIT_ORIGIN_REV_ID=9e60355679855b57ab63edf63944d3e23d2aec9a PiperOrigin-RevId: 458516880
1 parent c49f961 commit 15fa4db

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/java/com/google/android/material/textfield/TextInputLayout.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ public TextInputLayout(@NonNull Context context, @Nullable AttributeSet attrs, i
662662

663663
endLayout = new EndCompoundLayout(this, a);
664664

665-
setEnabled(a.getBoolean(R.styleable.TextInputLayout_android_enabled, true));
665+
final boolean enabled = a.getBoolean(R.styleable.TextInputLayout_android_enabled, true);
666666

667667
a.recycle();
668668

@@ -681,6 +681,11 @@ public TextInputLayout(@NonNull Context context, @Nullable AttributeSet attrs, i
681681

682682
addView(inputFrame);
683683

684+
// TextInputLayout#setEnabled sets the enabled state not only for TextInputLayout itself but
685+
// also for child views, so the method is called (and should be called) only after all child
686+
// views have been added.
687+
setEnabled(enabled);
688+
684689
setHelperTextEnabled(helperTextEnabled);
685690
setErrorEnabled(errorEnabled);
686691
setCounterEnabled(counterEnabled);

0 commit comments

Comments
 (0)