Remove Delay for android textPassword

2019-05-30 03:07发布

While enterting password inside EditText view, Characters are being shown and after some delay it is shown as DOT, i want to remove this delay. It should be displayed directly as DOT.

How do i do this on Android?

3条回答
疯言疯语
2楼-- · 2019-05-30 03:31

This is a user setting within Android, I do not believe that it is controllable from code. It is designed to aid the user in entering the correct password.

--Edit-- Further to the question askers comment, the setting can be found in:

Settings > Security > Make passwords visible

The above relates to Android ICS, the setting should be similar in previous versions.

查看更多
Juvenile、少年°
3楼-- · 2019-05-30 03:44

To Hide password forcefully,

android.provider.Settings.System.putInt(this.getContentResolver(),android.provider.Settings.System.TEXT_SHOW_PASSWORD, 0);

Note : It will not show any characters, Directly DOTs will be displayed without any delay inside your View having android:password attribute set to true

查看更多
冷血范
4楼-- · 2019-05-30 03:53

Use code from AOSP PasswordTransformationMethod.java and modify it to suit your needs. Create new class MyPasswordTransformationMethod from it and modify the Visible class inside it. It would also need to change rest of the code because it accesses some private properties, but they are mostly constants so it is quite easy.

private static class Visible
extends Handler
implements UpdateLayout, Runnable
{
    public Visible(Spannable sp, MyPasswordTransformationMethod ptm) {
        mText = sp;
        mTransformer = ptm;
        //postAtTime(this, SystemClock.uptimeMillis() + 1500); 
        //replaced with following line
        postAtFrontOfQueue(this);
    }

    public void run() {
        mText.removeSpan(this);
    }

    private Spannable mText;
    private MyPasswordTransformationMethod mTransformer;
}
查看更多
登录 后发表回答