add 添加密码黑点效果
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.jyn.vcview;
|
||||
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Created by jiao on 2019/8/8.
|
||||
*/
|
||||
public class AsteriskPasswordTransformationMethod extends PasswordTransformationMethod {
|
||||
@Override
|
||||
public CharSequence getTransformation(CharSequence source, View view) {
|
||||
return new PasswordCharSequence(source);
|
||||
}
|
||||
|
||||
private class PasswordCharSequence implements CharSequence {
|
||||
private CharSequence mSource;
|
||||
|
||||
public PasswordCharSequence(CharSequence source) {
|
||||
mSource = source; // Store char sequence
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(int index) {
|
||||
return '•'; // This is the important part
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return mSource.length(); // Return default
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return mSource.subSequence(start, end); // Return default
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class VerificationCodeView extends LinearLayout implements TextWatcher, V
|
||||
break;
|
||||
case NUMBERPASSWORD:
|
||||
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
|
||||
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
editText.setTransformationMethod(new AsteriskPasswordTransformationMethod());
|
||||
break;
|
||||
case TEXT:
|
||||
editText.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
|
||||
Reference in New Issue
Block a user