【问题标题】:Remove the navigation drawer icon and use the app icon to open去掉抽屉式导航图标,使用app图标打开
【发布时间】:2023-03-11 00:15:01
【问题描述】:

我想删除小的导航抽屉图标并在操作栏图标单击时打开左侧面板。我该怎么做?

实际上我正在创建一个类似于 Pinterest 的操作栏

【问题讨论】:

    标签: android android-actionbar navigation-drawer


    【解决方案1】:

    如果您想摆脱DrawerLayout 指示符,请不要使用ActionBarDrawerToggle。当您选择 ActionBar 主页功能调用 DrawerLayout.openDrawerDrawerLayout.closeDrawer 时切换 DrawerLayout,具体取决于当前状态。

    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);
        }
    

    另外,据我所知,Pinterest 不使用DrawerLayout

    【讨论】:

    • 它不是使用导航抽屉,它只是我需要的外观和感觉。但是你的代码已经帮助了我。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2022-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多