EditText hint shows extra spaces when inputType="textpassword"
Just wondered, am I the only one to encounter this "strange" behavior.
When placing an EditText inside my activity and setting its inputType="textPassword" as follow:
<EditText android:text="" android:id="@+id/EditText01"
android:hint="This is a hint" android:inputType="textPassword"
android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
The hint is displayed with bigger/double spaces between the words.
If I remove the inputType attribute it all goes back to normal. I couldn't find a known issue regarding this behavior.
BTW- If you wonder why this is important (it isn't that much) try putting two EditText widgets one below the other and set the inputType of one of them to "textpassword" it doesn't look good. Any idea on how to change the password or the other edittexts to use the same format ?
Thanks
PS. The question was add开发者_运维百科ed here first: http://groups.google.com/group/android-developers/browse_thread/thread/88738bb8d8046f6f but I didn't find an answer.
It happens because typeface automatically setted to monospace in case of password field. Setting android:typeface="normal"
on password field doesn't helps.
Here code from TextView sources:
if (password) {
setTransformationMethod(PasswordTransformationMethod.getInstance());
typefaceIndex = MONOSPACE;
} else if ((mInputType&(EditorInfo.TYPE_MASK_CLASS
|EditorInfo.TYPE_MASK_VARIATION))
== (EditorInfo.TYPE_CLASS_TEXT
|EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) {
typefaceIndex = MONOSPACE;
}
I can't find solution without implementing custom control with overriden typeface for hint.
P.S.: There is one solution, but it is not always acceptable - to set typeface to monospace on other EditText's.
Doing mEditText.setTypeface(Typeface.DEFAULT);
fixes the problem for me.
精彩评论