工具栏样式不起作用

Toolbar style doesn't work

我正在尝试制作一个带有白色文本颜色的浅蓝色工具栏:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        style="@style/ToolbarStyle"/>

在我的 styles.xml 中:

<style name="ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:background">?attr/colorPrimary</item>
</style>

但是有一个问题,文本颜色是黑色而不是白色

注意: 使用 android:themeapp:theme 而不是 style 将解决问题,但我仍然想知道,为什么不' t style 工作?

我想我现在明白问题了,

style 用于设置没有子视图的视图的样式。 android:themeapp:theme 用于设置视图及其子视图的样式。

因此,当涉及到工具栏的样式时,您可能希望对其及其子视图进行样式设置,这样 activity 标签也将被设置样式。