AClassyEngineer
AClassyEngineer

Reputation: 53

Creating and Using Custom Fonts in Android Studio with only Java

I am trying to use a custom font in my android project. I want to do this using only Java. Many tutorials I have found use a lot of XML, which I would like to avoid.

My project uses only a single activity but spans across several screens. From what I understand, placing text in the XML will span this text across all of my screens. I do not want this. Any and all help would be greatly appreciated.

Upvotes: 1

Views: 651

Answers (1)

Shanto George
Shanto George

Reputation: 994

In android, you can define your own custom fonts for the strings in your application. You just need to download the required font from the internet, and then place it in assets/fonts folder.

After putting fonts in the assets folder under fonts folder, you can access it in your java code through Typeface class.

Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/font name.ttf"); for more http://www.tutorialspoint.com/android/android_custom_fonts.htm

Upvotes: 1

Related Questions