84332

Android Studio Rendering Problems - Missing styles?

Question:

I get following error in the Preview window of Android Studio:

<blockquote>

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)

</blockquote>

I have created a custom style/theme. This is the regarding styles.xml:

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"> <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light"> <item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyActionBar</item> <item name="actionBarStyle">@style/MyActionBar</item> <item name="actionBarTheme">@style/MyActionBarTheme</item> </style> <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <item name="android:background" tools:ignore="NewApi">@color/white</item> <item name="titleTextStyle">@style/MyActionBar.ActionBar.TitleTextStyle</item> <item name="background">@color/bg_common</item> </style> <style name="MyActionBarTheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <item name="actionMenuTextColor">@color/title</item> <item name="colorControlNormal">@color/title</item> </style> <style name="MyActionBar.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textColor">@color/title</item> </style> </resources>

My layout file header looks like this:

<android.support.v4.widget.DrawerLayout 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!

Answer1:

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.

Answer2:

Another way is to change layout theme (near SDK preview version button) Works fine

Recommend

  • Translate animation to correct position in Android
  • Toolbar shifts up, when soft keyboard appears
  • Loop animation drawable
  • Gray line inside cardview :)?
  • Express JS Display Data By ID
  • Wrapping text in spinner android
  • XSD with multi occurrences unordered
  • Running jasmine tests for a component with NgZone dependency
  • How to resolve permission denied maybe missing internet permission?
  • How to create two column output from a single column
  • Splash Screen will not display
  • How can I get the choice “H2” back in the H2 consol?
  • WPF Template Binding in ToggleButton UserControl
  • Approximate Order-Preserving Huffman Code
  • JBoss External Properties Files in Classpath
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • Not able to aggregate on nested fields in elasticsearch
  • How Lists (specifically, RecyclerView with CardViews) in Android work
  • Code in Job's Script Block after Start-Process Does not Execute
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • Disable Enter in editText android
  • Cannot resolve symbol 'MyApi'
  • NHibernate Validation Localization with S#arp Architecture
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Why is an OPTIONS request sent to the server?
  • Pass value from viewmodel to script in zk
  • Bug in WPF DataGrid
  • Incrementing object id automatically JS constructor (static method and variable)
  • Redux, normalised entities and lodash merge
  • Release, debug version and Authorization Google?
  • bootstrap to use multiple ng-app
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • How to get icons for entities from eclipse?
  • Free memory of cv::Mat loaded using FileStorage API
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • how does django model after text[] in postgresql [duplicate]
  • Turn off referential integrity in Derby? is it possible?
  • unknown Exception android
  • JaxB to read class hierarchy