2016-04-15 27 views
2

是否可以更改android库项目中使用的组件的字体?更改库项目中使用的组件的字体

更具体地说:我正在使用库'Onboarder'在首次启动应用程序时显示介绍。现在,我得到了要求在显示文本的任何地方使用某种字体。通过'Caligraphy'库,我能够在其他地方引入新的字体。

我已经定义它适用于TextViews在我自己的布局文件样式:

<style name="TextViewStyle" parent="android:Widget.TextView"> 
    <item name="fontPath">fonts/myCustomFont.ttf</item> 
</style> 

的AppTheme:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    [...] 
    <item name="android:textViewStyle">@style/TextViewStyle</item> 
    [...] 
</style> 

库项目还使用普通的TextView没有任何造型,但不知何故,我样式不适用于他们。

有没有办法改变这些TextViews上的字体而不分叉GitHub回购?

这可能与:How to override styles of a library which has its own Activity

在此先感谢您的帮助。

回答

0

我终于找到了自己的问题:

它涉及到书法是如何工作的。我没有委托给attachBaseContext中的CalligraphyContextWrapper。扩展OnboardingActivity类和压倒一切的attachBaseContext()做的工作:

@Override 
protected void attachBaseContext(Context newBase) { 
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); 
} 
相关问题