Using Vector Drawable Compat

后端 未结 5 382
我寻月下人不归
我寻月下人不归 2021-01-30 16:30

I am making an android app with a few fragments. In one of these fragments, I have a toolbar with a back arrow as an image button.
In the XML File, I have the \"app:srcCompa

5条回答
  •  [愿得一人]
    2021-01-30 17:23

    add this line to your Gradle file under defaultConfig block:

    vectorDrawables.useSupportLibrary = true
    

    Also, you need to add this block of code in every activity or fragment where you're referencing drawables instead of images in srcCompat:

    static {
            AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        }
    

提交回复
热议问题