Change color of mask password selector
Ok guys I found the right answer, there IS a way to customize the color of it. https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#attr_android.support.design:passwordToggleTint
setPasswordVisibilityToggleTintList(ColorStateList)
Update: You can directly add following attribute in the TextInputLayout:
app:passwordToggleTint="#FFF"
rapid3642's answer pointed in the right direction but I still needed to find out what exactly would work.
Follow these steps to change the colour of your toggle drawable:
Create
selector_password_visibility_toggle
in~/res/color/
:<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- When password is shown as text, the drawable will be off_white coloured --> <item android:color="@color/off_white" android:state_checked="true"/> <item android:color="@android:color/white"/> </selector>
Add
passwordToggleTintMode
andpasswordToggleTint
to yourTextInputLayout
, as below:<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:passwordToggleTintMode="src_atop" app:passwordToggleTint="@color/selector_password_visibility_toggle" app:passwordToggleEnabled="true">
Now your TextInputLayout
will have its drawable colour changed.