Device font style theme prevent TextView Typeface to change the font on huawei device

131 views Asked by At

I'm trying to change the font of my Text View Using a typeface like this

Typeface tf = Typeface.createFromAsset(context.getAssets(), "fontName.ttf"));
TextView textView = (TextView) findViewById(R.id.textView1);
textView.setTypeface(tf);

but Huawei device has a font style customing that if you change the font there it will change the entire device font including my textView as well How can I prevent this?

1

There are 1 answers

0
Amirhosein On

If you are using fontFamily or typeface attributes in xml, remove theme. Also you can use Calligraphy project that enables actually setting custom font directly from a layout xml.