Reputation: 12552
I am trying to use Android Oreo custom font feature in my application.
It works fine if I set the font manually on each TextView
, but when trying to set it globally in my application theme, it has some issues.
My theme looks like this:
<style name="MyTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Other attributes -->
<item name="fontFamily">@font/custom_font</item>
</style>
The font is correctly applied in the BottomNavigationView
and the Button
s, but not in the Toolbar
or TextView
with a style
(like Body1
).
Is there a simple way to set a custom font on the whole application? Do I have to override each style to add the fontFamilly
attribute?
Update: I was using the style
attribute to set my text appearance, instead of android:textAppearance
. Using the later fixed most of my issues with custom font. Now, only the Toolbar
is still using the default font.
Upvotes: 1
Views: 188
Reputation: 2004
This is the perfect implementation.
https://futurestud.io/tutorials/custom-fonts-on-android-library-recommendations
Library:
https://github.com/chrisjenx/Calligraphy
Upvotes: 1
Reputation: 805
I don't think there is a way to apply font application wide, but activity wide is possible.
Checkout this Calligraphy, it works like a charm.
Upvotes: 1