question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Password Hint text does not have correct font applied

See original GitHub issue

If i try to use calligraphy for a password field as such:

<EditText
            style="@style/AppTheme.Font.Lgt"
            android:id="@+id/passwordText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="@dimens/text_size_med"
            android:hint="@string/password_hint"
            android:inputType="textPassword"
            android:text=""/>

It seems that the inputType attribute is forcing the hint into being monospaced (which seems to be odd, but normal android behavior with EditText). In this case, the font being applied by the style is ignored. Presumably because it is applied prior to android applying the inputType, and thus the typeface is getting overriden.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:4
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

33reactions
QiiqeAzuaracommented, Oct 11, 2016

@here @mattinger I try this way:

1.- remove android:inputType=“textPassword” from xml 2.- apply typeface using this great library @chrisjenx thanks 3.- set passwordtransformation in code: password.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); // No suggestions password.setTransformationMethod(PasswordTransformationMethod.getInstance());

DONE !!

3reactions
fingertrickscommented, Sep 7, 2015

@Sanjay-F 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.

Note: you need to bitwise OR the above variations with the appropriate:

  • InputType.TYPE_CLASS_TEXT
  • InputType.TYPE_CLASS_NUMBER

…when calling TextView.setInputType() otherwise Android doesn’t change the transformation type.

If for example you are using a button to toggle a password to be visible or not, you’ll have to manually set the Typeface after each call to setInputType() if you want to apply a custom Typeface. When toggling password visibility Android appears to reset the cursor position to the start of the EditText, so this snippet also sets the cursor to the end of the EditText.

mCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            int type = checked ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_TEXT_VARIATION_PASSWORD;
            mPassword.setInputType(InputType.TYPE_CLASS_TEXT | type);
            mPassword.setTypeface(customTypeface);
            mPassword.setSelection(mPassword.length());
        }
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Password hint font in Android - Stack Overflow
I acquired the custom typeface from username EditText and applied it to TextInputLayout of the password field. Now you don't need to set...
Read more >
<input type="password"> - HTML: HyperText Markup Language
If the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored completely. Note: Use ......
Read more >
Don't Use The Placeholder Attribute - Smashing Magazine
For someone who has never encountered it before, placeholder text may look like entered content, causing them to skip over the input. If...
Read more >
Working with the EditText | CodePath Android Cliffnotes
The EditText is the standard text entry widget in Android apps. ... If you do not see these styles applied within a DialogFragment,...
Read more >
ion-input: Custom Input Value Type Styling and CSS Properties
Types​. The input component is meant for text type inputs only, such as "text" , "password" , "email ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found