簡體   English   中英

無法建立Card-View

[英]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中:

  • 編譯'com.android.support:cardview-v7:23.1.0'

另外,我在樣式中使用的主題是

  • Theme.AppCompat.Light.NoActionBar

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 Studio,然后轉到:

在此處輸入圖片說明

當您錯誤地創建樣式或從現有樣式創建樣式時,通常會出現此問題。 因此,選擇“圖形布局”,然后選擇“ AppTheme”->具有藍星的選項卡。 並選擇任何預定義的樣式。 就我而言,“ Light”應該可以解決問題。

如果問題仍然存在,請暫時從主題中刪除<item name="cardStyle">@style/CardView.Light</item>並嘗試一下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM