Edit text Password Toggle Android

后端 未结 6 2032
滥情空心
滥情空心 2020-12-25 12:31

I am trying to show user the typed password in edit text whose input type is text Password.

I implemented gesturelistener over the toggle icon like this-

<         


        
6条回答
  •  醉酒成梦
    2020-12-25 13:30

     fragmentLoginBinding.imageViewEye.setOnClickListener(v -> {
            if (!isPasswordVisible) {
                fragmentLoginBinding.editTextPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                fragmentLoginBinding.imageViewEye.setImageDrawable(getResources().getDrawable(R.mipmap.feather_eye_crossed));
                isPasswordVisible = true;
            } else {
                fragmentLoginBinding.editTextPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
                fragmentLoginBinding.imageViewEye.setImageDrawable(getResources().getDrawable(R.mipmap.feather_eye));
                isPasswordVisible = false;
            }
        });
    

提交回复
热议问题