I did what his documentation has instructed upon setting up the 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 also placed the fonts in assets/fonts
, but to no avail.
Roboto still shows up as default font and not Open Sans. I tried applying it manually one by one to each TextView
, but still it doesn't work.
Any ideas on why this doesn't work?
More info: (In case it is useful) My miniSdkVersion is 15 and targetSdkVersion is 22. These are my 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 this is the custom theme that I am 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>