Can't use srcCompat for ImageViews in android

前端 未结 12 545
借酒劲吻你
借酒劲吻你 2020-12-03 00:38

I\'m using the Design Support Library 23.2. I\'ve added these lines in my build.gradle as my Gradle Plugin is version 1.5

defaultConfig {
        applicat         


        
12条回答
  •  醉话见心
    2020-12-03 01:03

    From, Android developer site

    This library is now a dependency of the v7 AppCompat library, allowing developers and AppCompat to easily use vector drawables.

    To use VectorDrawableCompat within an ImageButton or ImageView, use the app:srcCompat XML attribute or setImageResource() method.

    To keep referencing attribute IDs on API level 20 or lower, add the following appt flag to your build,gradle file:

    If you are building with Android Plugin for Gradle 1.5.0 or lower, add the following to your build.gradle file:

    android {
      defaultConfig {
        // Stops the Gradle’s automatic rasterization of vectors
        generatedDensities = []
      }
       // Flag that tells aapt to keep the attribute ids
      aaptOptions {
        additionalParameters "--no-version-vectors"
      }
    }
    

    If you are building with Android Plugin for Gradle 2.0.0 or higher, add the following to your build.gradle file:

    android {
      defaultConfig {
        vectorDrawables.useSupportLibrary = true
      }
    }
    

提交回复
热议问题