工具栏 - 灯光标题和灯光菜单

use*_*644 5 android styles android-appcompat

我目前正在开发一个实现Appcompat工具栏的应用程序.现在我的问题是如果我选择一个Light Actionbar作为基础,菜单是白色的,标题是黑色的.我希望两个都是白人.如果我将Dark Actionbar更改为base,则Text为白色,但菜单会变暗.

这是一个截图:

在此输入图像描述

我只想让标题文字颜色为白色.

这是我的styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/primary</item>
    <item name="colorAccent">@color/accent</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
</style>


</resources>
Run Code Online (Sandbox Code Playgroud)

这是toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"/>
Run Code Online (Sandbox Code Playgroud)

我希望你能帮助我.提前致谢!

Eug*_*nec 17

将其添加到工具栏元素

<!-- dark toolbar -->
<item name="android:theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<!-- light popup -->
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
Run Code Online (Sandbox Code Playgroud)


Abh*_*uri 4

您只需在 style.xml 中添加以下样式即可选择您想要的颜色,请根据您的要求更改颜色:

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

并确保将此属性添加到您的工具栏:

app:theme="@style/MyToolbarStyle"
Run Code Online (Sandbox Code Playgroud)