I am using TextInputLayout from Google material design library (version 1.4.0-alpha02).
If I set this property in the XML:
app:endIconMode="password_toggle"
A button is displayed to toggle between the password being displayed as plain-text or disguised.
Now if I try to do the same programmatically, as reported in the documentation I call
myTextInputLayout.endIconMode = END_ICON_PASSWORD_TOGGLE
The button appears correctly, but tapping it has no effect.
I tried to play a bit with all the methods and I found out that doing this:
myTextInputLayout.clearOnEndIconChangedListener()
myTextInputLayout.endIconMode = END_ICON_PASSWORD_TOGGLE
makes the button work: the content of the editText actually changes from plain-text to disguised, but the button stay the same. The icon is supposed to change depending on the state.
This is the layout I am using:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/myTextInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textColorHint="?android:textColorSecondary"
app:boxStrokeColor="@drawable/text_input_stroke_selector"
app:boxStrokeWidth="1dp"
app:endIconTint="?android:textColorSecondary"
app:errorIconDrawable="@null"
app:hintTextColor="?android:textColorSecondary">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textCursorDrawable="@null" />
</com.google.android.material.textfield.TextInputLayout>
Any idea?