Android Material Design: Failed to find style 'toolbarStyle' in current theme

可紊 提交于 2019-12-20 09:50:13

问题


I am trying to use the toolbar widget in android 21 with a custom style but I can't get rid off this error : Failed to find style 'toolbarStyle' in current theme.

Here is my layout xml file :

 <android.support.v7.widget.Toolbar
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/patient_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:theme="@style/AppTheme.Patient" />

Here is the Patient theme :

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
</style>

<style name="AppTheme.Patient" parent="AppTheme">
    <item name="colorPrimary">@color/patient_primary</item>
    <item name="colorPrimaryDark">@color/patient_primary_dark</item>
    <item name="colorAccent">@color/patient_accent</item>
    <item name="toolbarStyle"></item> <!-- what values to put here -->
</style>

I also tried to add toolbarStyle in item in my theme but I don't know the possible values. Am I missing something?


回答1:


You can use the style Widget.AppCompat.Toolbar.

<!-- Toolbar styles -->
    <item name="toolbarStyle">@style/Widget.AppCompat.Toolbar</item>



回答2:


I had the same problem event though my xml was correct. The solution was to: Set AppCompat theme in the Theme Select Checkbox, see pic.



来源:https://stackoverflow.com/questions/26984183/android-material-design-failed-to-find-style-toolbarstyle-in-current-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!