Cocoa
Cocoa

Reputation: 15

Why does the android studio gives me an error when I add the custom font?

When I add a font in my res/font directory, The red underline happens on the font. I tried adding font.xml, but that didn't work. Also, In the problems tab, it say "No errors found by the IDE"

Why does this error happen?

Upvotes: 0

Views: 2441

Answers (1)

user17668956
user17668956

Reputation:

Try this: You have to create a folder named font inside the res folder and copy your font inside the new folder.

enter image description here

All font names must be only: lowercase,a-z, 0-9, not contain spaces.

Now programmatically you should be able to use the font:

textView.setTypeface(ResourcesCompat.getFont(context, R.font))

Upvotes: 5

Related Questions