I recently found a bug with Material Design TexInputLayout and the way it makes the endIcon visible.
Consider you have setup everything right and have end icon enabled like:
inputLayout.endIconMode == END_ICON_CLEAR_TEXT
The problem is that if you define a focusListener like:
inputLayout.editText?.setOnFocusChangeListener { view, hasFocus -> ...}
and navigate to a screen which has this textInputLayout in it with some already filled text in like following pic
You'll notice that the endIcon is not showing, but if you tap on where it's supposed to be, it will work.
Even making sure it should be displayed by making it visible inputLayout.isEndIconVisible =
doesn't help. Through the debugging you can see you are hitting the public void setEndIconVisible(boolean visible)
with true value but still it doesn't make the icon visible.
I found a solution which I have posted as the answer.