Password hint font in Android

6 Answers

I found this useful tip from Dialogs Guide

Tip: By default, when you set an EditText element to use the "textPassword" input type, the font family is set to monospace, so you should change its font family to "sans-serif" so that both text fields use a matching font style.

For example


When an EditText is in password mode, it seems that the hint is shown in a different font (courrier?). How can I avoid this? I would like the hint to appear in the same font that when the EditText is not in password mode.

My current xml:

android:singleLine="true" />

This how to make input password that has hint which not converted to * and default typeface !!.

On XML :

android:hint="Input Password !."

On Activity :


thanks to : mango and rjrjr for the insight :D.

You can also use the


together with


The other answers are the right solution for most cases.

However, if you're using a custom EditText subclass to, say, apply a custom font by default, there's a subtle issue. If you set the custom font in the constructor of your subclass, it will still be overwritten by the system if you set inputType="textPassword".

In this case, move your styling to onAttachedToWindow after your super.onAttachedToWindow call.

Example implementation:


import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;

 * An EditText that applies a custom font.
 * @author
public class EditTextWithCustomFont extends EditText {

    private static Typeface customTypeface;

    public EditTextWithCustomFont(Context context) {

    public EditTextWithCustomFont(Context context, AttributeSet attrs) {
        super(context, attrs);

    public EditTextWithCustomFont(
            Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

     * Load and store the custom typeface for this app.
     * You should have a font file in: project-root/assets/fonts/
    private static Typeface getTypeface(Context context) {
        if (customTypeface == null) {
            customTypeface = Typeface.createFromAsset(
                    context.getAssets(), "fonts/my_font.ttf");
        return customTypeface;

     * Set a custom font for our EditText.
     * We do this in onAttachedToWindow instead of the constructor to support
     * password input types. Internally in TextView, setting the password
     * input type overwrites the specified typeface with the system default
     * monospace.
    @Override protected void onAttachedToWindow() {
        // Our fonts aren't present in developer tools, like live UI
        // preview in AndroidStudio.
        if (!isInEditMode()) {

In case you are using the calligraphy library in combination with a TextInputLayout and an EditText, the following code works well.

    EditText password = (EditText) findViewById(;
    TextInputLayout passwordLayout = (TextInputLayout) findViewById(;

    Typeface typeface_temp = password.getTypeface();
    password.setInputType(InputType.TYPE_CLASS_TEXT |


use the calligraphy library.

then it still wont update the password fields with the right font. so do this in code not in xml:

Typeface typeface_temp = editText.getTypeface();
editText.setInputType(inputType); /*whatever inputType you want like "TYPE_TEXT_FLAG_NO_SUGGESTIONS"*/
//font is now messed up ..set it back with the below call

The setTransformationMethod approach breaks android:imeOption for me, and allows carriage returns to be typed into the password field. Instead I'm doing this:


And am not setting android:password="true" in XML.