Is that right to make android.view.InflateException by using Vector drawables in android:background: line in a ImageView

前端 未结 2 1084
渐次进展
渐次进展 2021-01-28 03:59

I am facing android.view.InflateException in my app for some particular devices, in others phone it works fine. But i don\'t know why. Many others says that this pr

2条回答
  •  伪装坚强ぢ
    2021-01-28 04:24

    Make sure you have added vectorDrawables.useSupportLibrary = true inside defaultConfig in app/build.gradle.

    Like

    defaultConfig {
            vectorDrawables.useSupportLibrary = true
            ....
     }
    

    EDIT 1 In order to support vector in API less then 21. Also add this in onCreate method of Activity before setContentView.

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    

提交回复
热议问题