I want to change/display different icons for show password in android edittext. I am using following code to display icon.
In your Xml Make a RelativeLayout with TextInputLayout and Imageview
And in your Activity add onTouch() method for showing and hidding your password.
ImageView imagepass = (ImageView) findViewById(R.id.imagepassword);
imagepass .setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
editpass.setInputType(InputType.TYPE_CLASS_TEXT);
break;
case MotionEvent.ACTION_UP:
editpass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
break;
}
return true;
}
});