我想为 CardView 创建卡片项目 xml 布局并收到此错误。 Common solutions here没用(尝试了所有这些以及类似帖子中的其他人)。
这是我的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>
这是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>
这是 Manifest 中的相关部分:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
这是 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'
这是错误:
谢谢,
最佳答案
我也面临同样的问题。请通过选择菜单选项"file"→“使缓存无效/重新启动”重新启动 Android Studio。更多详情请点击链接:
关于Android Studio : Rendering Problems Missing styles-correct theme chosen for this layout, 无法找到带有 id 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33051106/