2016-04-15 29 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)); 
} 
相關問題