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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -