I was wondering if it's possible to define an embedded typeface to use for all TextView
s in a styles.xml
file.
I understand it's not as embedded typefaces have to be set programmatically on each element.
The code I use to do so is the following:
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/myfont.ttf");
TextView tv = (TextView) findViewById(R.id.myTextView);
tv.setTypeface(tf);
Now I'd like it if I was able to create the font from assets once and for all in an Activity
, an Application
singleton or anything persistent enough so I can reuse it in every View
definition to set the font on every element I want.
Any advice will be greatly appreciated!
[EDIT] Any comment on Mao's solution's up/down sides will be very welcome!