最近Material Design Components更新至了1.1.0,其中TextInputLayout新增了不少功能,要怎麼確切使用可以看這篇TextInputLayout,版本記得升級到1.1.0。
今天要記錄的是可以在輸入框EditText輸入框的末端有一個眼睛的Icon,點擊該眼睛,可以切換密碼明碼顯示,記得TextInputLayout的endIconMode與TextInputEditText的inputType都要設定。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.google.android.material.textfield.TextInputLayout | |
... | |
app:endIconMode="password_toggle"> | |
<com.google.android.material.textfield.TextInputEditText | |
... | |
android:inputType="textPassword"/> | |
</com.google.android.material.textfield.TextInputLayout> |