How to prevent TextView font changing, when we change the Device font style in Samsung devices
fontFamily
and typeface
attributes are related to android native fonts. If you want your TextViews
font to be always the same regardless the device font settings, you need to programmatically set a custom Typeface
.
Typeface tf = Typeface.createFromAsset(context.getAssets(), "fontName.ttf"));
TextView textView = (TextView) findViewById(R.id.textView1);
textView.setTypeface(tf);
As a side note, Calligraphy project enables actually setting custom font directly from a layout xml.