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 ref
I meet the same problem.Select theme to another one in preview can solve problem temporary.Like the image
Finally,I found out that there are AppTheme
and AppBaseTheme
in my styles.xml.
And AppTheme
has parent AppBaseTheme
.
The AppBaseTheme
has parent of one system style.
And every layout file use the theme AppTheme
.
Just change AppTheme
's parent to AppBaseTheme
's parent.
It solve the problem permanent.
I got this error after overriding action bar style like this. Also i lost action bar in preview.
<style name="general_app_theme" parent="@style/Theme.AppCompat">
<!-- for API level 11 -->
<item name="android:actionBarStyle">@style/action_bar_style</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/action_bar_style</item>
</style>
<style name="action_bar_style" parent="@style/Widget.AppCompat.ActionBar">
<!-- for API level 11 -->
<item name="android:height">@dimen/action_bar_height</item>
<item name="android:background">@color/action_bar_color</item>
<item name="android:displayOptions">showTitle</item>
<!-- Support library compatibility -->
<item name="displayOptions">showTitle</item>
</style>
So, problem is overriding theme by my custom. this is the reason, why I've changed AppCompat (from "Project Themes") to general_app_theme (from "Manifest Themes"). Now I have no this error and action bar in preview come back.
Try switching the theme in the design view to one of the options in "Manifest Themes". I'm guessing this is Because you are inheriting the theme from the manifest to support multiple api levels. It worked for me anyway.
What I usually do is the following: a Gradle Clean
, Rebuild
and Sync all my Gradle files
. After that I restart
Android Studio, and I go to:
Select Theme -> Project Themes -> AppTheme
It can be fixed by changing your theme in styles.xml from Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
and clean the project. It will surely help.
For Android Studio (or IntelliJ IDEA),
If everything looks OK in your project and you're still receiving the error in your layouts, try to 'Invalidate caches & restart'.
Enjoy a coffee while Android Studio is recreating caches & indexes.