如何在android中增加inputType密码点大小

sag*_*uri 7 android android-edittext android-inputtype

我有一个EditTextinputTypenumberPassword.我想更改替换文本的点大小.它对我来说非常小(android默认).我想增加点大小.我怎样才能做到这一点?

and*_*anu 8

尝试用这个ascii代码替换星号.
⚫ - ⚫ - 中黑圈⬤ - ⬤ - 黑色大圆圈

角色中间的大子弹的Unicode字符是什么?

 public class MyPasswordTransformationMethod 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
        }
        public char charAt(int index) {
            return '*'; // This is the important part
        }
        public int length() {
            return mSource.length(); // Return default
        }
        public CharSequence subSequence(int start, int end) {
            return mSource.subSequence(start, end); // Return default
        }
    }
}; 

text.setTransformationMethod(new MyPasswordTransformationMethod());
Run Code Online (Sandbox Code Playgroud)


dan*_*n87 7

解决方案提供了一半的工作,问题是该转换会将文本直接转换为“*”,而预期的行为是在输入新字符后或几秒钟后隐藏字符,以便用户有机会在隐藏之前看到真正的字符。如果你想保持默认行为,你应该做这样的事情:

/**
 * A transformation to increase the size of the dots displayed in the text.
 */
private object BiggerDotPasswordTransformationMethod : PasswordTransformationMethod() {

    override fun getTransformation(source: CharSequence, view: View): CharSequence {
        return PasswordCharSequence(super.getTransformation(source, view))
    }

    private class PasswordCharSequence(
        val transformation: CharSequence
    ) : CharSequence by transformation {
        override fun get(index: Int): Char = if (transformation[index] == DOT) {
            BIGGER_DOT
        } else {
            transformation[index]
        }
    }

    private const val DOT = '\u2022'
    private const val BIGGER_DOT = '?'
}
Run Code Online (Sandbox Code Playgroud)

这将用您想要的任何字符替换原始点。