Can't use srcCompat for ImageViews in android

前端 未结 12 535
借酒劲吻你
借酒劲吻你 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 01:03

    Call app:srcCompat instead of android:srcCompat .

    Don't

    android:srcCompat="@drawable/your_image"
    

    DO

    app:srcCompat="@drawable/your_image"
    

    Finally

        
    

    My gradle version is 1.5

    Upgrade your Gradle version.

    Solution

    Gradle Plugin 2.0+  
    com.android.tools.build:gradle:2.0.0-beta2
    

    Vector drawables allow you to replace multiple png assets with a single vector graphic, defined in XML. While previously limited to Lollipop and higher devices, both VectorDrawable and AnimatedVectorDrawable are now available through two new Support Libraries support-vector-drawable and support-animated-vector-drawable.

    Add this

        // Gradle Plugin 2.0+  
     android {  
       defaultConfig {  
         vectorDrawables.useSupportLibrary = true  
        }  
     } 
    

    You’ll note this new attribute only exists in the version 2.0 of the Gradle Plugin. If you are using Gradle 1.5 you’ll instead use

    // Gradle Plugin 1.5  
     android {  
       defaultConfig {  
         generatedDensities = []  
      }  
    
      // This is handled for you by the 2.0+ Gradle Plugin  
      aaptOptions {  
        additionalParameters "--no-version-vectors"  
      }  
     }  
    

    Go Through Support Vector Drawables

提交回复
热议问题