DEV Community

Wajahat Karim 🇵🇰
Wajahat Karim 🇵🇰

Posted on • Originally published at android.jlelse.eu on

Show/Hide Password in EditText in Android

How to show/hide the password dots in the EditText in android in one line

This article is part of Today I Learned series and was originally posted at my TIL Github Repository and my website at wajahatkarim.com

With the Material design and latest Material Theming, android developers often use TextInputLayout and its great password toggle functionality. But, sometimes your applications have legacy designs like this:

In these cases, you will have to show/hide password with a CheckBox and its OnCheckedChangeListener . So, recently I had to do this and relying on the TextInputLayout ‘s automatic password toggle functionality, I forgot how to do this. So, here’s how its done which I have learned.

Dummy Layout

Now, you can toggle the password with EditText#setTransformationMethod() like the code below:

Top comments (0)