Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add fonts folder on Android Studio?

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.

like image 448
GuiPab Avatar asked Feb 25 '15 00:02

GuiPab


1 Answers

In Android Studio, you can create assets directory under src/main.

So it looks like this

- src
  - main
    - java
    - res
    - assets
      - fonts

Update

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.

like image 59
ytRino Avatar answered Oct 17 '22 11:10

ytRino