android - Calligraphy library by chrisjenx is not working -


i did documentation has instructed upon setting default font:

 @override  protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setupdefaultfont();          setcontentview(r.layout.activity_main);          setuptoolbarandnavigationdrawer();   }    public void setupdefaultfont() {         calligraphyconfig.initdefault(new calligraphyconfig.builder()                         .setdefaultfontpath("fonts/opensans-regular.ttf")                         .setfontattrid(r.attr.fontpath)                         .build()         );   } 

i placed fonts in assets/fonts, no avail. roboto still shows default font , not open sans. tried applying manually 1 one each textview, still doesn't work.

any ideas on why doesn't work?

more info: (in case useful) minisdkversion 15 , targetsdkversion 22. these dependencies:

dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     compile 'com.android.support:appcompat-v7:22.2.0'     compile 'com.android.support:design:22.2.0'     compile 'com.android.support:recyclerview-v7:21.0.3'     compile 'com.android.support:cardview-v7:21.0.3'     compile 'de.hdodenhof:circleimageview:1.2.1'     compile 'uk.co.chrisjenx:calligraphy:2.1.0' } 

and custom theme using.

<resources>     <style name="myiit_theme" parent="theme.appcompat">         <item name="colorprimarydark">@color/primary_dark</item>         <item name="colorprimary">@color/primary</item>         <item name="android:textcolorprimary">@color/white</item>         <item name="android:windowbackground">@color/tertiary_dark</item>         <item name="android:activatedbackgroundindicator">@drawable/selected_drawer</item>         <item name="windowactionbar">false</item>         <item name="windownotitle">true</item>     </style> </resources> 

for configuration take effect, should set default font in oncreate() method of custom application class, instead of in activity.

also, instructions @ https://github.com/chrisjenx/calligraphy inject context, overriding method in activity follows:

@override protected void attachbasecontext(context newbase) {     super.attachbasecontext(calligraphycontextwrapper.wrap(newbase)); } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -