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.
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.
Wajahat Karim (@WajahatKarim) | Twitter
The latest Tweets from Wajahat Karim (@WajahatKarim). Android Developer. UI/UX Designer. Blogger. Writer…
Also, if you have any questions you’d like him to answer, contact him through his website at wajahatkarim.com with DEAR WAJAHAT in the subject line.