Remove the navigation drawer icon and use the app icon to open

耗尽温柔 提交于 2019-12-12 04:39:08

问题


I want to remove the small navigation drawer icon and open the left panel on actionbar icon click. How can I do this?

Actually I'm creating an Actionbar like Pinterest's


回答1:


If you want to get rid of the DrawerLayout indicator don't use the ActionBarDrawerToggle. To toggle the DrawerLayout when you select the ActionBar home affordance call DrawerLayout.openDrawer and DrawerLayout.closeDrawer depending on the current state.

switch (item.getItemId()) {
        case android.R.id.home:
            if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) {
                mDrawerLayout.closeDrawer(GravityCompat.START);
            } else {
                mDrawerLayout.openDrawer(GravityCompat.START);
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }

Also, from what I can tell Pinterest doesn't use a DrawerLayout.



来源:https://stackoverflow.com/questions/22452241/remove-the-navigation-drawer-icon-and-use-the-app-icon-to-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!