I'm developing an android app using Android Studio IDE, and i want to use customized fonts in this app.
I know that i have to create a folder called 'fonts' under the folder 'assets', but i can't.
All the time that i try, i have this:
res
-assets.fonts
Instead off:
res
-assets
--fonts
How can i create this folder?
I'm newbie on android development, so sorry about something.
In Android Studio, you can create assets
directory under src/main
.
So it looks like this
- src
- main
- java
- res
- assets
- fonts
Recent support library(from 26.0) officially supports fonts as Resource.
To use this, put fonts into src/main/res/font/
,
- src
- main
- java
- res
- font
Now you can use font as R.font.xxx
In layout xml
android:fontFamily="@font/myfont"
Or programmatically
Typeface typeface = ResourcesCompat.getFont(context, R.font.myfont);
textView.setTypeface(typeface);
This feature also enables you to create font family. Further information is on official docs.
You can also use Downloadable Font.