Can't use srcCompat for ImageViews in android

前端 未结 12 536
借酒劲吻你
借酒劲吻你 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:05

    Don't

    android:srcCompat="@drawable/wallpaper"
    

    Do

    app:srcCompat="@drawable/wallpaper"
    

    as it srcCompat attribute is actually defined within AppCompat library.

    Important you will need to add appropriate namespace for this.

    xmlns:app="http://schemas.android.com/apk/res-auto"

    Important

    what you are getting it seems like it is just a lint error that can be ignored. I have tried and have the same error, but it is working correctly.

    you can use tools:ignore="MissingPrefix" to avoid seeing this error temporarily.

提交回复
热议问题