DEV Community

Wajahat Karim πŸ‡΅πŸ‡°
Wajahat Karim πŸ‡΅πŸ‡°

Posted on β€’ Originally published at android.jlelse.eu on

3

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:

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay