How to use Calligraphy with multi-language support Oreo

前端 未结 3 1179
小蘑菇
小蘑菇 2021-01-03 04:14

I\'m developing an app that need to support multiple languages and if the language is RTL I have to apply a custom font. For the requirement I have created my Class that

3条回答
  •  长情又很酷
    2021-01-03 05:00

    Regarding S G's answer be aware that the new Calligraphy framework

    https://github.com/chrisjenx/Calligraphy

    requires a slightly different setup since attachBaseContext now requires the ViewPumpContextWrapper instead of the old CalligraphyContextWrapper.

    So the new call (in Kotlin) in the Activity looks like this:

    override fun attachBaseContext(newBase: Context) {  
         super.attachBaseContext(ViewPumpContextWrapper
             .wrap(LocaleHelper.onAttach(newBase)))
    }
    

提交回复
热议问题