question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextInputLayout] endIconMode change dynamically not possible

See original GitHub issue

Description: 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:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:10

github_iconTop GitHub Comments

6reactions
amzer-nazeercommented, Aug 7, 2019

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

5reactions
rodolfo-tenfencommented, Apr 20, 2020

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 to 0. 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 to 1 after the animation ends works. However, because the animation will still run, the icon will “blink”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add a drawable at the right end of a "TextInputLayout ...
I am using Material Design Text Input Field & EditText. Yes, I can do it with a simple EditText and an ImageView ,...
Read more >
TextInputLayout | Android Developers
Returns the text color used by the hint in both the collapsed and expanded states, or null if no color has been set....
Read more >
How to Use Material Text Input Layout in Android?
Go to app -> src -> main -> res -> values -> styles.xml and change the base application theme. Below is the code...
Read more >
EndIcon is default displayed when set text in TextInputLayout
I want to know how to hide by default. When the screen is rotated or setText () is displayed in the same way...
Read more >
TextInputLayout with a loading indicator - David Khol
Contents of each dropdown menu depend on the item selected in the previous dropdown because the data is dynamically loaded from the backend....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found