I have next style:
<style name="Text.Light">
<item name="android:fontFamily">@font/open_sans_light</item>
</style>
If I set it to TextView in xml via textAppearance like android:textAppearance="@style/Text.Italic" in design time it shows italic font, but in runtime it doesn't affect. But, if use fontFamily directly in TextView like android:fontFamily="@font/open_sans_italic" it works perfect in both cases (design and runtime).
What am I doing wrong? There is my font-family xml:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<font
android:font="@font/open_sans_regular"
android:fontStyle="normal"
android:fontWeight="400"
app:font="@font/open_sans_regular"
app:fontStyle="normal"
app:fontWeight="400" />
<font
android:font="@font/open_sans_italic"
android:fontStyle="italic"
android:fontWeight="400"
app:font="@font/open_sans_italic"
app:fontStyle="italic"
app:fontWeight="400" />
</font-family>
The problem was I choose textViewStyle in my AppTheme and there was fontFamily. According to post textAppearance has minimum priority and it can't override other styles which defined in theme or anywhere else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With