I use an EditText to enter password. And a CheckBox to show password or not. Below function is the part:
public void ShowPassword() { if (cb.isChecked()) {
use app:passwordToggleEnabled = true; available from Android support library version 24.2.0.