【问题标题】:Change Color of Navigation drawer icon and Overflow menu icon in toolbar更改工具栏中导航抽屉图标和溢出菜单图标的颜色
【发布时间】:2017-08-25 21:51:13
【问题描述】:

我在堆栈溢出中遵循了许多答案,但仍然无法找到我的问题的解决方案。
我已按照以下链接更改导航抽屉的颜色:
Navigation drawer change color

我按照以下方法更改溢出菜单的颜色:

 <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        style="@style/MyToolbarTheme.Base"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:titleTextColor="@android:color/white"
        />

在 Styles.XML 中

<style name="MyToolbarThemeSimple.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="actionOverflowButtonStyle">@style/overflow_simple</item>
    </style>
    <style name="overflow_simple" parent="MyToolbarThemeSimple.Base">
        <item name="android:color">@color/windowBackground</item>
        <item name="android:background">@color/windowBackground</item>
    </style>

我想将下面的导航抽屉和溢出菜单的颜色更改为白色

【问题讨论】:

  • 使用Theme.AppCompat.Light.NoActionBar代替父Theme.AppCompat.NoActionBar
  • 它不工作.....

标签: android android-toolbar navigation-drawer


【解决方案1】:

只需将以下内容添加到您的 MyToolbarThemeSimple.Base 即可调整溢出菜单点的颜色:

<style name="MyToolbarThemeSimple.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:theme">@style/MyToolbarTheme</item>
</style>

<style name="MyToolbarTheme">
    <!-- Used to for the title of the toolbar -->
    <item name="android:textColorPrimary">@android:color/white</item>
    <!-- Used to color back button and overflow menu dots -->
    <item name="android:textColorSecondary">@android:color/white</item>
</style>

对于ActionbarDrawerToggle,您需要将drawerArrowStyle 项目添加到您的AppTheme:

<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Other items -->
    <item name="drawerArrowStyle">@style/MyDrawerArrowToggleStyle</item>
</style>

<style name="MyDrawerArrowToggleStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@android:color/white</item>
</style>

【讨论】:

    猜你喜欢
    • 2015-10-23
    • 1970-01-01
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-16
    • 2016-12-20
    相关资源
    最近更新 更多