简体   繁体   中英

android.widget.Toolbar home button color (NOT support/v7/AppCompat toolbar)

I'm struggling to set the color of the "hamburger" icon on my android.widget.Toolbar, also most of the answers I find online apply to the support/v7 toolbar, but I'm using android.widget.Toolbar.

this is what my code looks like:

Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
        setActionBar(toolbar);
        ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_closed);
        drawerLayout.addDrawerListener(drawerToggle);
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        drawerToggle.syncState();

I would like to be able to style it in my styles.xml file, is it possible? I'm using material theme, this is my current styles.xml:

<resources>
    <style
        name="AppTheme"
        parent="@android:style/Theme.Material.Light.NoActionBar">

        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:textColor">@color/textColor</item>
        <item name="iconColor">@color/iconColor</item>
    </style>

    <style
        name="SplashTheme"
        parent="AppTheme">

        <item name="android:windowBackground">@drawable/splash_screen</item>
    </style>
</resources>

Thanks for your help.

Try creating this style in your styles.xml

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

And then add it to you Applications theme like so:

<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM