我刚刚下载并开始学习android L material design api。每当我在我的活动中使用CardView时,它都会给我这个错误Failed to find style with id 0x7f070001 in current theme
。
这是我的xml布局:
<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>
这是我的清单文件:
<?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
你知道这是什么意思吗?
发布于 2015-07-30 07:50:43
这是一个与Gradle同步相关的问题。尝试单击工具栏中的刷新按钮
发布于 2014-11-09 20:58:00
尝试运行应用程序,查看是否显示输出
发布于 2015-10-18 17:04:58
将android.support.v7.widget.CardView而不是RelativeLayout作为父布局
<?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" >
https://stackoverflow.com/questions/26625555
复制相似问题