android开发中的密码提示字体

android开发中的密码提示字体,android,passwords,Android,Passwords,当EditText处于密码模式时,提示似乎以不同的字体显示(courrier?)。我不想要这个我想要字体看起来一样我怎么避免这个 我当前的xml <EditText android:hint="@string/edt_password_hint" android:layout_width="fill_parent" android:layout_height="wrap_content" android:password="true" android:singleLine="true"

当EditText处于密码模式时,提示似乎以不同的字体显示(courrier?)。我不想要这个我想要字体看起来一样我怎么避免这个

我当前的xml

<EditText 
android:hint="@string/edt_password_hint"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:password="true"
android:singleLine="true" />`
`
可能重复的:

更改xml中的字体对我来说对提示文本也不起作用。我发现了两种不同的解决方案,其中第二种对我来说表现更好:

1) 从xml文件中删除android:password=“true”,改为在java中设置它:

EditText password = (EditText) findViewById(R.id.password_text);
password.setTransformationMethod(new PasswordTransformationMethod());
使用这种方法,提示字体看起来不错,但当您在编辑字段中键入时,在它变成密码点之前,您看不到纯文本中的每个字符。此外,在全屏输入时,不会显示点,而是以明文显示密码

2) 在xml中保留android:password=“true”。在Java中,还要设置字体和密码方法:

EditText password = (EditText) findViewById(R.id.register_password_text);
password.setTypeface(Typeface.DEFAULT);
password.setTransformationMethod(new PasswordTransformationMethod());
这种方法给了我想要的提示字体,并给了我想要的密码点行为

希望有帮助


<EditText 
android:hint="@string/edt_password_hint"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:password="true"
android:singleLine="true" 
android:fontFamily="Arial"
/>
将最后一行添加到编辑文本中。
你可以使用任何你喜欢的字体。

这篇文章的字面意思与: