问题
I get following error in the Preview window of Android Studio:
Rendering Problems 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
'?attr/actionBarPopupTheme' in current theme. (4 similar errors not
shown)
I have created a custom style/theme. This is the regarding styles.xml:
@style/MyActionBar
@style/MyActionBar
@style/MyActionBarTheme
@color/white
@style/MyActionBar.ActionBar.TitleTextStyle
@color/bg_common
@color/title
@color/title
@color/title
My layout file header looks like this:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/CustomActionBarTheme"
android:id="@+id/drawer_layout"
android:background="@color/bg_common_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
...
And in my manifest file I have added in the application tag:
android:theme="@style/CustomActionBarTheme"
Why do I get the error? I also choosed CustomActionBarTheme in my Preview windows as Theme. Am I missing something? Thanks for any advice in advance!
回答1:
Android Studio uses the latest SDK installed to preview layout files. This can lead to preview errors due to missing styles - switching to an older API level (e.g. from 23 to 22) can fix this.
回答2:
Another way is to change layout theme (near SDK preview version button)
Works fine
来源:https://stackoverflow.com/questions/34076213/android-studio-rendering-problems-missing-styles