android – Font doesn't changing on device but on emulator do-ThrowExceptions

Exception or error:

I have an app and i’m trying to change the whole app font, from default to “Assistant-Light” font.

I searched the web and tried all the solutions that suggested but still the same result.

I created a font folder, with the font (assistant_light.ttf) and font family (assistant_font.xml) files.

I’ve tried to change the font from the styles.xml file and set it as a theme for the app like this:

styles.xml

<style name="AppTheme" parent="Base.Theme.AppCompat">
    <item name="android:fontFamily">@font/assistant_font</item>
</style>

MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    // rest of code...

The min SDK version is 19, and my device Android version is 4.4.2

Any idea how to fix it?

Thanks!

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *