Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

android 5.0 lollipop - Color of animated ActionBarDrawerToggle in ActionBar

How can i change the color of animated ActionBarDrawerToggle icons in ActionBar, using AppCompat-v7 (v21)? I tried this, but doesn't work. Thanks.

myActionBarActivity.java

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mLeftDrawer = (LinearLayout) findViewById(R.id.left_drawer);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.string.drawer_open, R.string.drawer_close)

values/styles.xml

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

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

UPDATE: solved, there was this entry <item name="actionBarWidgetTheme"> in my theme which probably overlapped <item name="drawerArrowStyle">. I removed it and now all works.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This should work..

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

and in your parent theme..

<style name="AppTheme" parent="AppBaseTheme">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        .
        .
        .
</style>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...