EditText password = (EditText) view.findViewById(R.id.etPassword);
if (Build.VERSION.SDK_INT != android.os.Build.VERSION_CODES.KITKAT) {
Typeface typeface = TypefaceUtil.overrideFont(getContext(), "SERIF", "fonts/calibri.ttf");
password.setTypeface(typeface);
}
Run Code Online (Sandbox Code Playgroud)
这是XML的布局 TextInputLayout
<android.support.design.widget.TextInputLayout
android:id="@+id/inpPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/button_margin_small">
<android.support.design.widget.EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:hint="@string/set_pass"
android:inputType="textPassword"
android:maxLength="@integer/pass_max"
android:maxLines="1"
android:password="true"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用此代码,但我的密码提示字体样式与我设置的不同.