【问题标题】:Change color of navigation drawer button (back button)?更改导航抽屉按钮(后退按钮)的颜色?
【发布时间】:2015-07-01 16:44:27
【问题描述】:

在我的应用程序中,我使用操作栏和导航抽屉。操作栏中有一个按钮用于打开和关闭导航抽屉。我想把它的颜色改成红色。我该怎么做?

【问题讨论】:

标签: android android-actionbar navigation-drawer


【解决方案1】:

解决了这个Appcombat v7 Toolbar with drawer changing colors
在您的主题风格中执行以下操作:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@color/your_red_color</item>
</style>

【讨论】:

    【解决方案2】:

    您必须按照 Material Theme 设置您的应用主 color: (official documentation)

    res/values/colors.xml

    <resources>
      <!-- inherit from the material theme -->
      <style name="AppTheme" parent="android:Theme.Material">
        <!-- Main theme colors -->
        <!--   your app branding color for the app bar -->
        <item name="android:colorPrimary">@color/primary</item>
        <!--   darker variant for the status bar and contextual app bars -->
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <!--   theme UI controls like checkboxes and text fields -->
        <item name="android:colorAccent">@color/accent</item>
      </style>
    </resources>
    

    另一种方法是自己生成图标:Toolbar Navigation Hamburger Icon missing

    【讨论】:

      猜你喜欢
      • 2015-04-11
      • 1970-01-01
      • 2015-04-28
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多