Published in


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

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:

Wajahat Karim is a graduate from NUST, Islamabad, an experienced mobile developer, an active open source contributor, and co-author of two books Learning Android Intents and Mastering Android Game Development with Unity. In his spare time, he likes to spend time with his family, do experiments on coding, loves to write about lots of things (mostly on blog and medium) and is passionate contributor to open source. In June 2018, one of his library became #1 on Github Trending. His libraries have about 2000 stars on Github and are being used in various apps by the developers all around the globe. Follow him on Twitter and Medium to get more updates about his work in Writing, Android and Open Source.

Also, if you have any questions you’d like him to answer, contact him through his website at with DEAR WAJAHAT in the subject line.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store