无法构建卡片视图

Unable to build Card-View

我正在尝试在我的布局中插入卡片视图,但出现此渲染错误。

Missing styles.
Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout,
or fix the theme style references.
Failed to find style with id 0x7fff001a in current theme.

我已经将其包含在应用程序的 gradle 中:

此外,我在样式中使用的主题是

styles.xml 在这里:

 <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primaryColor</item>
    <item name="colorPrimaryDark">@color/primaryColorDark</item>
    <item name="colorAccent">@color/accentColor</item>
    <item name="cardStyle">@style/CardView.Light</item>
</style>

卡片视图在这里:

<android.support.v7.widget.CardView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:cardCornerRadius="4dp"
    app:elevation="5dp"/>

错误消息讨论了 ID 为 0x7fff001a 的样式。它指的是什么?

尝试Gradle CleanRebuildSync all Gradle files。之后 restart Android 工作室,然后前往:

当您错误地创建样式或从现有样式创建样式时,通常会出现此问题。所以 select "Graphical Layout" select "AppTheme"-->带有蓝色星号的选项卡。和 select 任何预定义样式。在我的情况下 "Light" 应该可以解决问题。

如果问题仍然存在只是暂时的,请从您的主题中删除 <item name="cardStyle">@style/CardView.Light</item> 并试一试。