0

I know how to do it programatically as such:

    TextView txt = (TextView) findViewById(R.id.custom_font);
    Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
    txt.setTypeface(font);

But how does one do this as a style that can be inherited and extended? I just want to declare a TextView to have a common < Style /> tag

< TextView /> has an attribute called "typeFace" but valid values are only "normal", "sans", "serif", and "monospace"

http://developer.android.com/reference/android/widget/TextView.html#attr_android:typeface

Mark Lapasa
  • 1,644
  • 4
  • 19
  • 37
  • 2
    http://stackoverflow.com/questions/2376250/custom-fonts-and-xml-layouts-android This post should help you out. – draksia Feb 23 '12 at 18:41

2 Answers2

1

As far as I know you are not able to do this. You can not load a font in via xml and make it into a style. However, I sure hope that someone is able to prove me wrong on this because I would love to have this available.

Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
1

This is not the answer but I figured out a very sad workaround.

Extend the TextView component class

In the constructor of the subclass, fire off the code

TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(context.getAssets(), "Chantelli_Antiqua.ttf");
txt.setTypeface(font);

...yuck

Mark Lapasa
  • 1,644
  • 4
  • 19
  • 37