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.

The issue is that
ClearTextEndIconDelegatehas a defaultOnFocusChangeListenerwhich when you click on the editText it runs an animation which through it the alpha value of the private/internalendIconView(which holds the endIconDrawable)changes from 0 to 1. When you override and set your ownOnFocusChangeListeneryou actually discard this process and setting theinputLayout.isEndIconVisible = trueenables the view but you can't see it still. I didn't find any way to access to the parent view and change the alpha. Actually you can by doing something likeTake a look at image below you'll get how I ended up the above:
But this is not a great solution also if the hierarchy of the view changes it won't work anymore.
Ultimate Solution
What I came with is the invoking the original
OnFocusChangeListenerwithin myOnFocusChangeListenersomething like :