Using font in XML in API < 26

后端 未结 5 1004
旧时难觅i
旧时难觅i 2020-12-09 08:02

https://developer.android.com/preview/features/working-with-fonts.html

Android API 26 supports this but do we have a support library that can provide use of fonts as

5条回答
  •  误落风尘
    2020-12-09 08:46

    According to Google it is supported on Android 4.0+ (API 14+) as long as these conditions are met:

    • You are using the support library version 26.0.0-beta1 or later
    • You are using AppCompat

    Sources:

    Fonts in XML - Using the support library

    Support Library revision history

    I was hoping I could use this in app widgets on Android versions earlier than 8 (API 26), however it's not possible, as AppCompatTextView cannot be used in app widgets. None of the third party alternatives to Android O's 'Fonts in XML' such as the Caligraphy library work in app widgets either.

    The only alternative for app widgets is using an ImageView instead of a TextView and using RemoteViews methods such as setImageViewUri(...) and setImageViewBitmap(...), both of which are problematic.

提交回复
热议问题