abstract:在Google發(fā)布了support:design:23+以后我們發(fā)現(xiàn)有這么一個東西TextInputLayout,先看下效果圖:<android.support.design.widget.TextInputLayout android:id="@+id/pwdLayout" android:layout_width=&qu
在Google發(fā)布了support:design:23+以后我們發(fā)現(xiàn)有這么一個東西TextInputLayout,先看下效果圖:
<android.support.design.widget.TextInputLayout android:id="@+id/pwdLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:passwordToggleEnabled="true" > <EditText android:id="@+id/pwdEdt" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/edt_pwd_hint" android:maxLines="1" android:inputType="textPassword" /> </android.support.design.widget.TextInputLayout>
只要在布局中添加屬性app:passwordToggleEnabled=”true”就可以實現(xiàn)當(dāng)EditText的inputType=”textPassword”的時候在輸入框的最右邊就會顯示眼睛一樣的開關(guān)來顯示和隱藏密碼,需要的同學(xué)不妨試試看。
更多關(guān)于Android中實現(xiàn)EditText密碼顯示隱藏的方法請關(guān)注PHP中文網(wǎng)(m.miracleart.cn)其他文章!