Android Selector Drawable with VectorDrawables srcCompat

后端 未结 5 1093
轻奢々
轻奢々 2020-12-04 08:50

I\'m facing a problem with the new backward compatibility with VectorDrawables. In the Support Library 23.2 was a new feature for backward compatibility with Android VectorD

5条回答
  •  有刺的猬
    2020-12-04 08:56

    Some things have changed since I asked this question, so I will answer it myself.

    With Support Library 23.4.0 the support for VectorDrawables from Ressources was reenabled: Android Support Library 23.4.0 available now

    You can find more information on that in this cast from the Google I/O 2016: What's new in the support library - Google I/O 2016

    You need to add this to every Activity where you want to use VectorDrawables on devices below Android 5.0 (Codename Lollipop, API level 21):

    static {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    }
    

    So you can now use VectorDrawables in DrawableContainers but it can still cause some issues as mentioned in the sources above so use it with caution.

    I did not reenable this feature in my app so far but I will change a lot of my icons to VectorDrawables with my next major release and will then dive deeper into this topic.

提交回复
热议问题