Reputation: 4494
To use fonts in android now , we directly use android:fontFamily="@font/yourFont"
in android and we can apply the font on a view directly.
If we have different versions of same font such as bold,italic,normal we can create a font-family as::
font/lobster.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
android:fontStyle="bold"
android:fontWeight="600"
android:font="@font/lobster_bold" />
</font-family>
android:fontFamily="@font/lobster_italic"
but with lobster.xml
reference.Upvotes: 0
Views: 784
Reputation: 6495
In your xml use
android:fontFamiliy="@font/lobster"
android:textStyle="italic"
Or in code
textview.setTypeface(textview.getTypeface(), Typeface.ITALIC);
Upvotes: 1