EditText inputType设置textpassword,hint字体变化问题

1,642 阅读1分钟

直接上图

输入框部分为自定义控件,passwordInput inputType为testpassword,效果就是图一,hint的字体被改变了,查了一下修改typeface即可,如果代码设置inputType,那typeface需要设置在其后

  et.inputType = resInputType
  et.typeface = Typeface.DEFAULT

原因是typeface是在setInputType中设置的

......
if (isPassword) {
            setTransformationMethod(PasswordTransformationMethod.getInstance());
            setTypefaceFromAttrs(null/* fontTypeface */, null /* fontFamily */, MONOSPACE,
                    Typeface.NORMAL, -1 /* weight, not specifeid */);
        }