【问题标题】:Navigation Drawer icon on the top right is showing Back arrow icon insted of Hamburger icon右上角的导航抽屉图标显示后退箭头图标而不是汉堡图标
【发布时间】:2015-05-06 08:23:41
【问题描述】:

我已经使用 Navigation Drawer Activity 创建了一个新的 android 应用程序。 当我执行应用程序时,右上角的图标显示后箭头,但它必须是 3 行的图标。

图标R.drawable.ic_drawer是这个

在 NavigationDrawerFragment 类中。

// ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    ) 

当我执行应用程序时,我会在右侧看到箭头图标。

选择后图标也是一样的。

我现在如何更改它?

【问题讨论】:

  • 当您从列表中选择任何项目时,它会变回汉堡包。
  • android.support.v4.app.ActionBarDrawerToggle 还是android.support.v7.app.ActionBarDrawerToggle?第一个被弃用了。否则它对我来说似乎是正常的行为,因为它会在关闭时恢复到原来的形状。
  • 这是一个正常的状态,抽屉是打开的。关闭它(通过选择一个项目),看看它是否变为汉堡包。我也认为是Top Left 而不是Top Right
  • 它是android.support.v7.app.ActionBarActivity;选择后它也将是相同的箭头图标。
  • 选择后用图片更新了我的问题。

标签: android navigation-drawer


【解决方案1】:

希望这会有所帮助,我通过这种方式解决了上述问题。 @shkschneider 是对的。使您的代码工作导入android.support.v7.app.ActionBarDrawerToggle

mDrawerToggle = new ActionBarDrawerToggle(this,
                mDrawerLayout,
                R.string.drawer_open,
                R.string.drawer_close){

            @Override
            public void onDrawerClosed(View drawerView) {
                getSupportActionBar().setTitle(mTitle);
                invalidateOptionsMenu();
            }

            @Override
            public void onDrawerOpened(View drawerView) {
                getSupportActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu();
            }
        };

【讨论】:

    【解决方案2】:

    对不起,我来晚了,但这可能对其他人也有帮助。

    您只需要添加以下行,它就可以正常工作。 :)

    mDrawerToggle.setDrawerIndicatorEnabled(false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-15
      相关资源
      最近更新 更多