0

I am confused in using Roboto font in my project. Basically I don't know the proper way to use this font. I have multiple .tff files and I want to apply Roboto font to my whole project. minsdk is 15.

EDIT I just want to include the fonts via XML files.

  • @Kling Klang Why duplicate? I just dont want to apply the styling to TextView only. I am talking about whole application and also I dont want to do this via java code. –  Jan 14 '18 at 09:51
  • Please read the duplicate, see the various answers and understand that once you define a style all the views (with the proper attributes set) will inherit the properties defined in that style. – Phantômaxx Jan 14 '18 at 10:59

1 Answers1

2

STEP 1/

Start by creating a folder named assests then inside that folder create another one named folder and import your *.ttf files to that folder

STEP 2/

Now import this before start writing the code given below:

import android.graphics.Typeface;

Now implement the following code to your class:

// Font path
String fontPath = "fonts/Face Your Fears.ttf";

// text view label
TextView txtGhost = (TextView) findViewById(R.id.ghost);

// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);

// Applying font
txtGhost.setTypeface(tf);

I suggest you follow this tutorial right here it will guide step-by-step through using external fonts in Android Studio

Thorvald
  • 3,424
  • 6
  • 40
  • 66
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/18510102) – June7 Jan 13 '18 at 23:00
  • you are absolutely right , the answer is updated now, thanks for the heads-up – Thorvald Jan 13 '18 at 23:13
  • I want to do it via styling and XML only. Is there any way that I can use custom fonts single time and it applies to whole application? –  Jan 14 '18 at 09:54