How to increase inputType password dot size in android
The solution provided half works, the problem is that that transformation will transform the text directly to the '*' while the expected behavior is to hide the char once a new char has been input or after a few seconds so the user gets the chance to see the real char before hiding it. If you want to keep the default behavior you should do something like this:
/**
* 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 = '●'
}
This will replace the original dot with whatever char you want.
Try to replace asterisk with this ascii codes.
⚫ - ⚫ - Medium Black Circle
⬤ - ⬤ - Black Large Circle
What would be the Unicode character for big bullet in the middle of the character?
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());