简体   繁体   中英

Changing navigation drawer icon

我有一个问题,我有不同的活动,具有不同的背景颜色(白色或蓝色),菜单图标也必须是白色或蓝色(与活动背景相反),我在更改活动后找不到正确的更改方式, 我怎样才能做到这一点?

U must do like this:

mDrawerToggle = new ActionBarDrawerToggle(
            this,                 
            mDrawerLayout,         
            R.drawable.ic_drawer, //<-- This is the icon provided by Google itself
            R.string.drawer_open,
            R.string.drawer_close 
            )

This in setUp() method.

And dont forget to add these code:

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    // Sync the toggle state after onRestoreInstanceState has occurred.
    mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    mDrawerToggle.onConfigurationChanged(newConfig);
}

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