更改导航抽屉图标
Changing navigation drawer icon
我有一个问题,我有不同的 activity 和不同的背景颜色(白色或蓝色),菜单图标也需要是白色或蓝色(与 activity 背景相反),我更改后找不到正确的更改方法activity,我该怎么办?
你必须这样做:
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
)
这在 setUp()
方法中。
不要忘记添加这些代码:
@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);
}
我有一个问题,我有不同的 activity 和不同的背景颜色(白色或蓝色),菜单图标也需要是白色或蓝色(与 activity 背景相反),我更改后找不到正确的更改方法activity,我该怎么办?
你必须这样做:
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
)
这在 setUp()
方法中。
不要忘记添加这些代码:
@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);
}