Android Studio:渲染问题缺少为此布局选择的样式 - 正确主题,无法找到具有id的样式

mic*_*ael 16 android android-layout android-xml android-theme android-studio

我想创建卡项xml布局CardView并获取此错误.这里的常见解决方案没有奏效(尝试过所有这些以及其他类似帖子).

这是我的xml:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="3dp"
        card_view:cardElevation="4dp">


    </android.support.v7.widget.CardView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是以下相关部分styles.xml:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/primary_accent</item>
</style>

<!--Theme for Tool Bar (Action Bar)-->
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
    <item name="android:textColorPrimary">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这是以下相关部分Manifest:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)

这是gradle build脚本的相关部分:

compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
Run Code Online (Sandbox Code Playgroud)

这是错误:

在此输入图像描述

谢谢,

AVI*_*ALI 40

我也面临同样的问题.请通过选择菜单选项"文件"→"无效缓存/重新启动"重新启动Android Studio.有关详细信息,请点击链接:

http://www.unknownerror.org/opensource/harvesthq/chosen/q/stackoverflow/13439486/missing-styles-is-the-correct-theme-chosen-for-this-layout


Har*_*GUL 11

您可以通过将当前主题更改为合适的主题来解决此问题.每个主题都不适合所有类型的视图.通过使用主题组合框,我们可以解决这个问题.
这是问题所在 在此输入图像描述

1.首先去主题栏并按下它
在此输入图像描述


2.如下图所示更改主题 在此输入图像描述 现在你改变了你的主题.如果选定的主题适合您的视图,它将呈现.

在此输入图像描述