【发布时间】:2019-12-26 15:14:10
【问题描述】:
我正在尝试在 Android Studio 的密码提示字段中使用自定义字体。
在 XML 中将“编辑文本”设置为 inputType="textPassword" 后,字体将变为与我选择的字体不同的字体。所有其他编辑文本都具有正确的自定义字体。
我已尝试在 java 代码中遵循 this 解决方案(将 Typeface.DEFAULT 替换为 R.font.my_font),但没有任何反应
EditText password = (EditText) findViewById(R.id.register_password_text);
password.setTypeface(R.font.my_font);
password.setTransformationMethod(new PasswordTransformationMethod());
我也尝试过this 解决方案,但没有成功
Typeface cache = edtPassword.getTypeface();
edtPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
edtPassword.setTypeface(cache);
对尝试什么或这些解决方案中可能缺少什么有任何想法?
PS:我使用的是 montserrat_regular 字体
【问题讨论】: