Error inflating class android.support.v7.widget.Toolbar. My mistake or bug? -
i had following rendering issue on layouts when using sdk 22 preview them.
error inflating class android.support.v7.widget.toolbar.
java.lang.nosuchfielderror: view_theme
in case , problem styles.xml
:
xml rendering problem:
<resources> <style name="appbasetheme" parent="theme.appcompat.light.darkactionbar" /> <!-- base application theme. --> <style name="apptheme" parent="appbasetheme"> <item name="colorprimary">@color/primary</item> <item name="colorprimarydark">@color/primary_dark</item> <item name="coloraccent">@color/accent</item> <item name="android:textcolorprimary">@color/primary_text</item> </style> </resources>
xml without problem:
<resources> <style name="appbasetheme" parent="@style/theme.appcompat.light.darkactionbar" /> <!-- base application theme. --> <style name="apptheme" parent="appbasetheme"> <item name="colorprimary">@color/primary</item> <item name="colorprimarydark">@color/primary_dark</item> <item name="coloraccent">@color/accent</item> <item name="android:textcolorprimary">@color/primary_text</item> </style> </resources>
notice how had add @style/
in parent reference. seems solve problem (after rebuild).
question, error on side, or bug? many tutorials don't put (including official android page)
gradle:
compilesdkversion 22 buildtoolsversion '22.0.1' minsdkversion 15 targetsdkversion 22 classpath 'com.android.tools.build:gradle:1.1.0'
final note: i'm not using toolbar.
edit :
reading so question.
if activity extends appcompactactivity
, parent theme should be
<style name="appbasetheme" parent="@style/theme.appcompat.light.darkactionbar" />
where as, if using actionbaractivity
, theme should
<style name="appbasetheme" parent="theme.appcompat.light.darkactionbar" />
i think difference on purpose, , not bug. please feel free correct me if wrong cannot conferm same anywhere yet.
old :
to use toolbar action bar, first thing need disable decor provided action bar. easiest way have theme extend theme.appcompat.noactionbar (or light variant).
use :
<style name="appbasetheme" parent="theme.appcompat.light.noactionbar" />
Comments
Post a Comment