Android Studio:渲染问题缺少样式-为此布局选择了正确的主题,无法找到带有 id 的样式 [英] Android Studio: Rendering Problems Missing styles-correct theme chosen for this layout, Failed to find style with id

查看:27
本文介绍了Android Studio:渲染问题缺少样式-为此布局选择了正确的主题,无法找到带有 id 的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 CardView 创建卡片项目 xml 布局并收到此错误.

谢谢,

解决方案

我也遇到了同样的问题.请通过选择菜单选项文件"→使缓存无效/重新启动"来重新启动 Android Studio.更多详情请点击链接:

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

I want to create card item xml layout for CardView and getting this error. Common solutions here not worked (tried them all and others from similar posts).

This is my 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>

This is the relevant part of 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>

This is the relevant part from the Manifest:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

This is the relevant part from gradle build script:

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'

And this is the error:

Thanks,

解决方案

I was also facing the same issue. Please restart Android Studio by selecting the menu option "File" → "Invalidate Caches / Restart". For more details please follow the link:

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

这篇关于Android Studio:渲染问题缺少样式-为此布局选择了正确的主题,无法找到带有 id 的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆