I want to change/display different icons for show password in android edittext. I am using following code to display icon.
<android.support.design.widget.TextInputLayout
android:id="@+id/layoutTextInput"
android:textColorHint="@color/aluminium">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/editTextValue"
android:imeOptions="actionNext"
android:layout_marginBottom="8dp"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
I want to use custom icons instead of normal icons(eye-icon). Please help me.
app:passwordToggleEnabled="true">
In your Xml Make a RelativeLayout with
TextInputLayout
andImageview
And in your Activity add
onTouch()
method for showing and hidding your password.I implement it using text.. that is 'Show' and 'Hide'
Hope this help for you..!!
Create a new drawable file and named it as show_password_selector.xml
and in your layout file, add
app:passwordToggleDrawable
attribute inTextInputLayout
:For Reference: https://www.youtube.com/watch?v=dW0YIV0Z9qk
With AndroidX and Android Material all you need is -> app:passwordToggleEnabled="true"