Home  >  Q&A  >  body text

java - 请问如何设置toolbar里的DrawerLayout按钮的颜色?

就是上图那个按钮

PHP中文网PHP中文网2711 days ago508

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:54:33

    SetIcon

    reply
    0
  • 阿神

    阿神2017-04-18 09:54:33

    By default you should use style.xml中的AppTheme主题(这个可以在AndroidManifest.xml as seen in). Assuming that is the case, then you can change the color of the drawer button by:

    1. Enterstyle.xml;

    2. Add an inheritance from Widget.AppCompat.DrawerArrowToggle的style,这里叫做"DrawerArrowStyle"。在里面加上你想要的颜色,这里比如@color/colorBlue;

    3. Add a line named drawerArrowStyle to style "AppTheme".

    In this way, style has the following two items:

    <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/colorBlue</item>
    </style>
    

    Run it again and you will see the result.

    reply
    0
  • Cancelreply