android - Efficiency when overriding font for multiple views -


there 2 ways "globally" override font used in android.

creating class extends view object , setting type face, i.e.

public class textviewrobotoregular extends textview {      public textviewrobotoregular(context context, attributeset attrs) {         super(context, attrs);          if (!isineditmode()) {             typeface typeface = typeface.createfromasset(getcontext().getassets(), "fonts/roboto-regular.ttf");             settypeface(typeface);                     }     } } 

the other being defining style , setting typeface there

<style name="codefont" parent="@android:style/textappearance.medium">     <item name="android:typeface">monospace</item> </style> 

so question is, more memory-efficient?

also, there anyway make reference in xml file assets/fonts/<fontname>.ttf file? i'm trying have view objects have same font, them reference 1 spot if decide change font.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -