The hint font is affected by the EditText text font, which is affected by the android:typeface. Android:typeface has three values: "Sans", "serif", "monospace", see Source:
In Setinputtype:
if (Ispassword) { Settransformationmethod (passwordtransformationmethod.getinstance ()); Settypefacefromattrs (NULL/* fontFamily */, monospace, 0); } else if (Isvisiblepassword) { if (mtransformation = = Passwordtransformationmethod.getinstance ()) { ForceUpdate = true; } Settypefacefromattrs (NULL/* fontFamily */, monospace, 0); } else if (Waspassword | | wasvisiblepassword) { //Not in password mode, clean up typeface and transformation Setty Pefacefromattrs (NULL/* fontFamily */,-1,-1); if (mtransformation = = Passwordtransformationmethod.getinstance ()) { forceupdate = true; } }
In the constructor:
if (password | | passwordinputtype | | webpasswordinputtype | | numberpasswordinputtype) { Settransformationmethod ( Passwordtransformationmethod.getinstance ()); Typefaceindex = monospace; } else if (meditor! = null && (Meditor.minputtype & (Editorinfo.type_mask_class | editorinfo.type_mask_variation) = = (Editorinfo.type_class_text | Editorinfo.type_text_variation_password)) { typefaceindex = monospace; }
You can see that when the password bar is the font is
Monospace
DefaultSans, so will cause font inconsistency, find the root cause of the problem then there is the solution, set the default is good:
Passedit.settypeface (Typeface.sans_serif);
Edittext Password property is true causes hint full-width problem