带有黑暗工具栏的Android Theme.AppCompat.Light(用于浅色文字)

Jef*_*tin 12 android android-appcompat material

我有一个应用程序Theme.AppCompat.Light,我需要使用它,所以Dialogs有轻主题.但这会使我的工具栏中的文字变黑,我宁愿它变成白色.我试过设置工具栏的具体app:themeAppCompat.Dark.Actionbar,但没有运气...我搜索了一段时间,但没有找到一个具体的问题和答案.

这是我的默认AppTheme:

<style name="AppTheme.Parent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/blue</item>
    <item name="colorPrimaryDark">@color/dark_blue</item>
    <item name="colorAccent">@color/pink</item>

    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这是我的toolbar.xml:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="@dimen/abc_action_bar_default_height_material"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)

reV*_*rse 17

要更改标题中的标题颜色,Toolbar只需将属性添加android:textColorPrimary工具栏样式即可.

有关工具栏的更多属性,请参阅以下示例.

<style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
    <!-- Used to for the title of the Toolbar -->
    <item name="android:textColorPrimary">#fff</item>
    <!-- Used to for the title of the Toolbar when parent is Theme.AppCompat.Light -->
    <item name="android:textColorPrimaryInverse">#fff</item>
    <!-- Used to color the text of the action menu icons -->
    <item name="android:textColorSecondary">#fff</item>
    <!-- Used to color the overflow menu icon -->
    <item name="actionMenuTextColor">#fff</item>
    <!-- Color of the Toolbar -->
    <item name="android:background">#455a64</item>
</style>
Run Code Online (Sandbox Code Playgroud)

结果

结果的图片