Reputation: 193
I just downloaded and started learning android L material design api. Whenever I use CardView in my activity it gives me this error Failed to find style with id 0x7f070001 in current theme
.
This is my xml layout :
<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>
And this is my manifest file :
<?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>
and this is the exact message it displays :
Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style with id 0x7f070001 in current theme
EDIT : So I restarted eclipse this is the new message it displays.
Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup Exception details are logged in Window > Show View > Error Log The following classes could not be instantiated: - android.support.v7.widget.CardView
any ideas on what it means?
Upvotes: 16
Views: 9195
Reputation: 334
This solution worked for me:
Go to File -> Invalidate Caches / Restart and click on Invalidate and Restart.
Upvotes: 0
Reputation: 127
try to use this code in your activity style
<style name="StyledIndicators" parent="@android:style/Theme.Light">
<item name="vpiCirclePageIndicatorStyle">@style/CustomCirclePageIndicator</item>
</style>
<style name="CustomCirclePageIndicator">
<item name="fillColor">#000000</item>
<item name="strokeColor">#000000</item>
<item name="strokeWidth">1dp</item>
<item name="radius">6dp</item>
<item name="centered">true</item>
</style>
see this link failed-to-find-style-vpicirclepageindicatorstyle
Upvotes: 0
Reputation:
It's an issue related with Gradle sync. Try clicking the refresh button in the toolbar
Upvotes: 7
Reputation: 731
put android.support.v7.widget.CardView as your parent layout instead of 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" >
Upvotes: 1