error: attribute 'xxx:cardBackgroundColor' not found

error: attribute 'com.zy.gank.gankio:cardBackgroundColor' not found.
Message{kind=ERROR, text=error: attribute 'com.zy.gank.gankio:cardBackgroundColor' not found., sources=[E:\gankio\app\src\main\res\layout\recycler_view_item.xml:17], original message=, tool name=Optional.of(AAPT)}
在使用cardview时,报出了这样的错误。

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    app:cardBackgroundColor="@color/app_color_blue"
    app:cardCornerRadius="10dp"
    app:cardElevation="10dp"
    app:cardPreventCornerOverlap="true"
    app:layout_constraintTop_toTopOf="parent"

找不到app:xx的所有属性,一开始以为v7包里面有cardview了,就没有导入cardview的包,没想到是这个原因,弄了几个小时没找到原因,后来才试试导入

implementation 'com.android.support:cardview-v7:27.1.1'

就可以了。

猜你喜欢

转载自blog.csdn.net/weixin_40119478/article/details/82149159