android - Different font for Some activities using Calligraphy Library -
i using calligraphy library using custom font in application. set custom font whole application default font using calligraphyconfig
, in application
class in #oncreate()
method , working fine. problem comes when need change font of 1 activity (settingsactivity).
i tried using custom font in style didn't change font of activity.
following code of style
<style name="englishactivitiestheme" parent="apptheme"> <item name="android:textviewstyle">@style/apptheme.widget.textview</item> </style> <style name="apptheme.widget.textview" parent="android:widget.holo.light.textview"> <item name="fontpath">fonts/roboto-regular.ttf</item> </style>
in manifest
<activity android:name=".settingsactivity" android:theme="@style/englishactivitiestheme" android:parentactivityname=".mainactivity" > <meta-data android:name="android.support.parent_activity" android:value=".mainactivity" /> </activity>
am doing wrong custom font though style method? or there better method of doing this?
looks it's because of appcompat creating different version of buttons/textviews @ runtime.
in calligraphy startup in application, add line:
.addcustomstyle(appcompattextview.class, android.r.attr.textviewstyle)
to end like:
@override public void oncreate() { super.oncreate(); calligraphyconfig.initdefault(new calligraphyconfig.builder() .setdefaultfontpath("fonts/some-other-custom-font.ttf") .addcustomstyle(appcompattextview.class, android.r.attr.textviewstyle) .setfontattrid(r.attr.fontpath) .build() ); //.... }
and should take care of textviews.
edit:
this should fixed https://github.com/chrisjenx/calligraphy/pull/191, snapshot.
Comments
Post a Comment