Reputation: 168
Well I'm tring to change a textview font family to a custom font I used this documentation from Google
But my app crash at launch Well here is what i did exactly
I created an Android resource directory and I added my font to it (using windows explorer) Here is a screenshot of that directory
Then I created an Android resource file named myfont in that directory here here is its content:
<?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/droidkufi_regular" />
</font-family>
Ps: the font file name is droidkufi_regular.ttf (it was with upper case letter but i changed it to lower case)
Than here is my text view
<TextView
.
.
android:fontFamily="@font/myfont"
.
.
/>
I run the app every things looks good on the gradle build but when the app launch on my phone It crash ("App Name" has stopped) I also tried restarting my phone, clearing the app data, reinstall, and also installing the app on an emulator.
well here is the logcat: in pastebin since it kinda long (packagename is com.mypackagename) https://pastebin.com/cjh67DZm
NB: this only happens with custom fonts, when I use a system font like this: android:fontFamily="cursive" It works as supposed.
Upvotes: 1
Views: 147
Reputation: 99
use both :
android:font="@font/yourFont"
and :
app:font="@font/yourfont"
Upvotes: 1