首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用CardView安卓L (api 21)时“在当前主题中找不到id为0x7f070001的样式”

使用CardView安卓L (api 21)时“在当前主题中找不到id为0x7f070001的样式”
EN

Stack Overflow用户
提问于 2014-10-29 16:18:27
回答 6查看 8.4K关注 0票数 16

我刚刚下载并开始学习android L material design api。每当我在我的活动中使用CardView时,它都会给我这个错误Failed to find style with id 0x7f070001 in current theme

这是我的xml布局:

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.flip.tesla"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.flip.tesla.MainActivity$PlaceholderFragment" >

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    app:cardElevation="10dp" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World"
        android:textSize="15sp" />
</android.support.v7.widget.CardView>

</RelativeLayout>

这是我的清单文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

这是它显示的确切消息:

缺少样式。是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。

在当前主题中找不到id为0x7f070001的样式

eclipse EDIT :所以我重新启动了eclipse,这是它显示的新消息。

呈现期间引发

异常:无法将com.android.layoutlib.bridge.MockView强制转换为android.view.ViewGroup异常详细信息记录在窗口>显示视图>错误日志中无法实例化以下类:- android.support.v7.widget.CardView

你知道这是什么意思吗?

EN

回答 6

Stack Overflow用户

发布于 2015-07-30 07:50:43

这是一个与Gradle同步相关的问题。

票数 7
EN

Stack Overflow用户

发布于 2014-11-09 20:58:00

尝试运行应用程序,查看是否显示输出

票数 1
EN

Stack Overflow用户

发布于 2015-10-18 17:04:58

将android.support.v7.widget.CardView而不是RelativeLayout作为父布局

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_gravity="center"
 card_view:cardCornerRadius="4dp" >

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="2dp"
    android:orientation="vertical"
    android:weightSum="100" >
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26625555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档