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

Time:03-09

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?

CodePudding user response:

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))
  • Related