Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android材质设计:在当前主题中找不到样式“toolbarStyle”_Android_Android Theme_Material Design - Fatal编程技术网

Android材质设计:在当前主题中找不到样式“toolbarStyle”

Android材质设计:在当前主题中找不到样式“toolbarStyle”,android,android-theme,material-design,Android,Android Theme,Material Design,我正在尝试使用android 21中的工具栏小部件,但我无法摆脱这个错误: 在当前主题中找不到样式“toolbarStyle” 以下是我的布局xml文件: <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 21中的工具栏小部件,但我无法摆脱这个错误: 在当前主题中找不到样式“toolbarStyle”

以下是我的布局xml文件:

 <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" />
以下是患者主题:

<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>

我还尝试在我的主题中的项目中添加工具栏样式,但我不知道可能的值。我错过什么了吗

您可以使用style Widget.AppCompat.Toolbar

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

虽然我的xml是正确的,但我遇到了相同的问题事件。 解决方案是:在主题选择复选框中设置AppCompat主题,参见图。

此外,您可以在@style/Widget.AppCompat.toolbar中将@android:style用于基于主题的任何样式。我猜您必须在SDK中安装android支持库Manager@Riten,你可以选择项目主题。上述问题也为我提出。你的解决方案奏效了。谢谢@davidai如果你像我一样,你可能已经错过了根节点中的tools:context标签,它可以帮助预览选择正确的主题。看见