I want to add custom bold font in my font_family.xml
. I did not find bold fontStyle="bold"
in font family developer doc. It only have normal
or italic
attribute. Here is font_family.xml
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/lobster_regular" />
<font
android:fontStyle="italic"
android:fontWeight="400"
android:font="@font/lobster_italic" />
</font-family>
So i have to use style like
<style name="fontBoldStyle" parent="@android:style/TextAppearance.Small">
<item name="android:fontFamily">@font/montserrat_semi_bold</item>
</style>
or like this
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat_semi_bold"/>
My question
- What does
fontStyle
attribute do? Even i did not provide italic font tofont_family.xml
, and settextStyle="italic"
then my font is italic. - how to add custom bold font in font family and set
android:fontStyle="bold"
infont_family.xml
so i dont have to create different styles and i just have to settextStyle="bold"
So what is a solution that i can set 3 of my fonts - normal, bold, italic
to font_family.xml, and set android:fontFamily="@font/font_family"
on TextView and then i can use android:textStyle="bold"
or italic, or normal?