I've been logging in recently , Registration page , It needs to show or hide the password , So a simple display and hide function is made .

Key classes TextView.setTransformationMethod(TransformationMethod
method), among TransformationMethod There are two subclasses :

* HideReturnsTransformationMethod hidden carriage return
* PasswordTransformationMethod Password type
critical code :
@OnClick(R.id.iv_psw_eye) void clickPswEye() { int tag = Integer.parseInt(
pswEyeIV.getTag().toString()); if (tag == 1) {// Show password pswEyeIV.setTag(2);
pswEyeIV.setImageResource(R.mipmap.icon_psw_not_eye); passwordET.
setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } else {
// Hide password pswEyeIV.setTag(1); pswEyeIV.setImageResource(R.mipmap.icon_psw_eye);
passwordET.setTransformationMethod(PasswordTransformationMethod.getInstance());
} }
I use ImageView of Tag Property stores the type of the current password input box ,1 Is password type ,2 Is the display type . Key codes of layout components are as follows :
<RelativeLayout android:layout_width="match_parent" android:layout_height=
"45dp" android:layout_gravity="center" android:layout_marginTop="26dp" android:
background="@drawable/bg_edit_login" android:paddingLeft="26dp"> <EditText
android:id="@+id/password_ET" android:layout_width="match_parent" android:
layout_height="match_parent" android:layout_toLeftOf="@+id/iv_psw_eye" android:
background="@null" android:gravity="center_vertical" android:hint=" Please input a password "
android:inputType="textPassword" android:maxLines="1" android:textColor=
"@color/color_666666" android:textColorHint="@color/color_999999" android:
textSize="13sp" /> <ImageView android:id="@+id/iv_psw_eye" android:layout_width=
"wrap_content" android:layout_height="match_parent" android:
layout_alignParentRight="true" android:paddingLeft="20dp" android:paddingRight=
"26dp" android:src="@mipmap/icon_psw_eye" android:tag="1" /> </RelativeLayout>
screenshot :

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage MySQL Basics Commonly used sentence ( Add / delete / modify query )C Language of a Gobang game implementation QT5.9 Use of learning notes QSqlQuery Method of Qt Getting Started tutorial 【 Basic controls 】QCalendarWidget calendar control java Polymorphic array of web Front end signature plug-in _signature_pad Plug in implements electronic signature function centos7 install RabbitMqspringboot use redis Experiment 4 Automated test tools - software test