Broken TextInputLayout with support library 24.2.0
See original GitHub issueAndroid support library 24.2.0 introduced these changes to TextInputLayout
:
public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
...
+ mInputFrame = new FrameLayout(context);
+ mInputFrame.setAddStatesFromChildren(true);
+ addView(mInputFrame);
...
}
...
public void addView(View child, int index, final ViewGroup.LayoutParams params) {
if (child instanceof EditText) {
+ mInputFrame.addView(child, new FrameLayout.LayoutParams(params));
+
+ // Now use the EditText's LayoutParams as our own and update them to make enough space
+ // for the label
+ mInputFrame.setLayoutParams(params);
+ updateInputLayoutMargins();
+
setEditText((EditText) child);
- super.addView(child, 0, updateEditTextMargin(params));
} else {
...
Anvil’s rendering breaks TextInputLayout
as it always tries to replace FrameLayout
inside with EditText
. I really like Anvil’s reactive views approach, however, I’d like to also use latest stable support library. Any suggestions how to overcome this? Thank you.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:8
Top Results From Across the Web
Broken TextInputLayout with support library 24.2.0 · Issue #81 · anvil ...
Broken TextInputLayout with support library 24.2.0 #81 ... Anvil's rendering breaks TextInputLayout as it always tries to replace FrameLayout inside with ...
Read more >TextInputLayout not showing hint in IME extract mode, on 24.2 ...
After upgrading to support library 24.2.0 TextInputEditText stopped showing hints in IME extract mode ( works fine on 24.1.0 ). Library used (support-v4, ......
Read more >Support Library Revision Archive - Android Developers
This page provides details about older Support Library package releases. ... Note: Release 24.2.0 removes support for Android 2.2 (API level ...
Read more >Android TextInputLayout Password toggle not visible in new ...
The TextInputLayout password toggle is now disabled by default to avoid unnecessarily overwriting developer-specified end drawables.
Read more >Android Support Library v24.2 released : r/androiddev - Reddit
EDIT 3: As much as I greatly appreciate breaking up support-v4 into smaller ... Found a bug in design library 24.2.0, notice the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, this is a bugger. I don’t see how Anvil can nicely handle this. Support Library developers have broken too many things here - they’re injecting views, in the unexpected order, and they’ve overridden addView() behavior, mess with LayoutParams, and to make it even worse - they’ve overridden one particular
addView()
implementation with one particular use case (XMLs).Still, Anvil is a cool little library that allows to work this around (even with no xmls):
Here I’m creating a child view directly using its constructor. Then I assign some ID to it (it may not be unique, but it should be unique within the TextInputLayout). Then I find that edit text view by ID, set the rest of its attributes as one would normally do with Anvil, finally, I skip all the child views that were not created by Anvil. This brings the expected results.
However, I have to agree, that if the view is designed to be used exclusively from XML - there is no reason to make it even more painful. I would agree with the suggestion to use an XML layout for this view hierarchy specifically.
By the way, there is a good chance that existing XML-related issues are all gone, you may check the most recent marser branch - I’ve rewritten too much to describe it here, but you may look at #99 for a bigger picture.
@jakubkulhan Did you check if xml and withId will make any difference?