views:

165

answers:

3

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:

<EditText 
android:hint="@string/edt_password_hint"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:password="true"
android:singleLine="true" />
A: 
android:typeface="monospace"

You can use that, or whatever other font you want.

Mike
Nope, doesn't change the font of the hint when password is true.
hgpc
+4  A: 

Changing the typeface in xml didn't work on the hint text for me either. I found two different solutions, the second of which has better behavior for me:

1) Remove android:password="true" from your xml file and instead, in set it in java: EditText password = (EditText) findViewById(R.id.password_text); password.setTransformationMethod(new PasswordTransformationMethod());

With this approach, the hint font looks good but as you're typing in that edit field, you don't see each character in plain text before it turns into a password dot.

2) Leave android:password="true" in your xml. In Java, ALSO set the typeface: EditText password = (EditText) findViewById(R.id.register_password_text); password.setTypeface(Typeface.DEFAULT);

This approach gave me the hint font I wanted AND gives me the behavior I want with the password dots.

Hope that helps!

manisha
It did help. Thanks!
hgpc
A: 

like the above but make sure the fields do not have the bold style in xml as they will never look the same even with the above fix!

Rrackham