[TextInputLayout] endIconMode change dynamically not possible
See original GitHub issueDescription: Changing endIconMode of a TextInputLayout (combination with TextInputEditText) does not work dynamically.
To reproduce: Set a textbox endIconMode first to “clear”.
After that set endIconMode to “custom” and set a custom icon drawable - produces strange results.
The end icon is not visible anymore.
After pressing/tapping the area where the endIcon should reside, the icon is visible for a short period of time (milliseconds) showing the changed icon.
Expected behavior: endIconMode should change dynamically without causing it to break endIcon functionality
Source code: Initial state:
textBox.endIconMode="clear"
Later (change from an event outside / button click / something else):
textBox.endIconMode="custom"
textBox.endIconDrawable = someDrawable
Android API version: 28
Material Library version: 1.1.0-alpha09
Device: Samsung Galaxy S9 / Emulator
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:10
Top GitHub Comments
I too ran into this issue… I have an exposed drop down menu using AutoCompleteTextView inside TextInputLayout.
After the user select an item from the drop down… I set the endIcon to END_ICON_CLEAR_TEXT to give the user the option to clear his selection. Works perfect until this… When it is cleared, I want to set the endIcon to END_ICON_DROPDOWN_MENU… It doesnt show… Tried adding a TextWatcher but nothing helped
I have the same problem, I’m trying to change between CUSTOM and CLEAR_TEXT modes depending on whether the
TextInputEditText
is empty or not. So CUSTOM when empty and CLEAR_TEXT otherwise.What I found is that, when the
TextInputEditText
is cleared (by pressing the Clear Text button or by deleting the text with the keyboard), the Clear Text button disappears using an animation, which sets its alpha to0
. So when the mode is changed to CUSTOM and the icon replaced, the animation is not stopped and it ends up hiding the new icon. Forcing the button’s alpha to go back to1
after the animation ends works. However, because the animation will still run, the icon will “blink”.