本文介绍了缺少向上导航图标ICS动作条切换到棒棒糖工具栏后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用动作栏和导航抽屉的活动有许多碎片。它使回家了。我已经实现正确的逻辑,只有顶层的片段显示操作栏中抽屉切换图标,其他的片段显示箭头。我所取得的:

I have an activity with many fragments that uses action bar and navigation drawer. It has "home as up" enabled. I have implemented proper logic that only top level fragments show action bar drawer toggle icon, other fragments show up arrow. I achieved this by:

mDrawerToggle.setDrawerIndicatorEnabled(false);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerList);

现在老V4支持库ActionBarDrawerToggle成为德precated。我已经与新的工具栏切换到V7版本合力得到材料的设计外观。之后,当抽屉处于打开状态向上箭头显示正确的,但在执行上述code时,它完全消失。

Now old v4 support library ActionBarDrawerToggle became deprecated. I've switched to v7 version together with new Toolbar to get Material Design look. After that when drawer is open "up" arrow is correctly displayed, but when the above-mentioned code is executed it disappears completely.

难道是支持库中的错误或我必须做不同的事情,以显示向上箭头抽屉指标呢?

Is it a bug in support library or I have to do something different to show "up" arrow instead of drawer indicator?

推荐答案

您是否尝试过使用 getV7DrawerToggleDelegate()获取主题了指标。getThemeUpIndicator()后设置禁用指标呢?

Have you tried to get themed up indicator using getV7DrawerToggleDelegate().getThemeUpIndicator () and set it after you disable the indicator?

由于当指示器被禁用 ActionBarDrawerToggle 试图设置previous指标。

Because when the indicator is disabled ActionBarDrawerToggle tries to set the previous indicator.

ActionBarDrawerToggle 来源:

public void setDrawerIndicatorEnabled(boolean enable) {
    if (enable != mDrawerIndicatorEnabled) {
        if (enable) {
            setActionBarUpIndicator((Drawable) mSlider,
                    mDrawerLayout.isDrawerOpen(GravityCompat.START) ?
                            mCloseDrawerContentDescRes : mOpenDrawerContentDescRes);
        } else {
            setActionBarUpIndicator(mHomeAsUpIndicator, 0);
        }
        mDrawerIndicatorEnabled = enable;
    }
}

编辑:

由于 ActionBarActivity 的德precation,你应该使用 getDrawerToggleDelegate()。getThemeUpIndicator()

As of deprecation of ActionBarActivity, you should use getDrawerToggleDelegate().getThemeUpIndicator ()

这篇关于缺少向上导航图标ICS动作条切换到棒棒糖工具栏后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:22