Hellow there, I am using kotlin for setting the font of the hint for the TextInputLayout as:
passwordTextLayout.typeface = Typeface.createFromAsset(context.assets, "fonts/af/myfont.ttf")
where myfont.ttf is some personal font file
it only works when the hint resides/placed inside the edittext of the textinputlayout, but when I clicked the edittext and start typing the hint collapsed up and the it changed the font to some default font!
I want to use the same type face to the hint in both the conditions i.e when the hint is inside the edittext and when it collapses.
Picture when hint resides inside the edittext (see the f for font changes):
Picture when user clicks inside the edittext the font changes as (check out the character f):
Ok, apparently there is a problem with typefaces in TextInputLayouts with inputType password
. If you use TextView.setInputType() with any of:
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
InputType.TYPE_TEXT_VARIATION_PASSWORD
InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
InputType.TYPE_NUMBER_VARIATION_PASSWORD
...then Android applies a Monospace typeface.
I think, that the better workaround would be to do the following:
PasswordTransformation
in code:. .
password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
password.setTransformationMethod(PasswordTransformationMethod.getInstance());