2

We can change fonts using java code as described here:

Roboto font in my android app

My question: Is there a way to specify the fonts in the xml layout file itself? Or better still, can we specify the font in the AndroidManifest.xml, so that it reflects across the app?

Thanks, Rahim.

Community
  • 1
  • 1
Rahim
  • 918
  • 1
  • 12
  • 23
  • Check it out here, http://stackoverflow.com/questions/2376250/custom-fonts-and-xml-layouts-android – King RV Jan 20 '12 at 08:36

2 Answers2

1

You can use a theme that contains all the styles you want to use in your app (included fonts). The use of the schema is declared in the manifest

http://developer.android.com/guide/topics/ui/themes.html

jegumi
  • 1,162
  • 10
  • 17
0

If you want to manage custom fonts without headache, I suggest you to use a library that handles the hard part, like caching the fonts in memory and allows to preview the display in the Layout Editor. Then you can focus on creating the styles for your titles or texts.

I have done such a library called Smart Fonts for Android.

It is easy to install with gradle, and it is well documented.

It is available on GitHub:

https://github.com/smart-fun/SmartFonts

enjoy!

Arnaud SmartFun
  • 1,573
  • 16
  • 21