Password visiblity Toggle in edittext is not working properly

2.2k views Asked by At

When the password is visible then the cross on eye icon is not appear.How to put the cross sign when password is visible on the eye icon.

<android.support.design.widget.TextInputLayout
                app:passwordToggleTint="@color/white"
                app:passwordToggleEnabled="true"
                android:textColorHint="#818893"
                android:layout_weight="0.4"
                android:layout_width="match_parent"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_height="match_parent"
                app:hintTextAppearance="@style/TextAppearance.AppCompat">

                <EditText
                    android:padding="10dp"
                    android:imeOptions="actionGo"
                    android:maxLines="1"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/password"
                    android:hint="Password"
                    android:inputType="textWebPassword" />
            </android.support.design.widget.TextInputLayout>
2

There are 2 answers

1
Niko Adrianus Yuwono On BEST ANSWER

Update your support library to 25.1.0 there are some known issue with password toggle visibility in 24.x

Refer to these issues:

0
Kush Patel On

Try this code

<android.support.design.widget.TextInputLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="@dimen/login_linear_pwd_container_margin_top"
            android:background="@drawable/login_edittext_gradient"
            android:gravity="center"
            app:hintEnabled="false"
            app:passwordToggleDrawable="@drawable/password_visibility"
            app:passwordToggleEnabled="true">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/txtPassword"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@null"
                android:hint="@string/login_password_title"
                android:imeOptions="flagNoExtractUi"
                android:inputType="textPassword"
                android:paddingBottom="10dp"
                android:paddingLeft="@dimen/login_edittext_left_padding"
                android:paddingRight="@dimen/login_edittext_left_padding"
                android:paddingTop="10dp"
                android:textColor="@color/txt_black"
                android:textColorHint="@color/tab_text_color" />
        </android.support.design.widget.TextInputLayout>