Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 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 Reply

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...