【问题标题】:Android ActionBar custom view hides ActionBarDrawerToggleAndroid ActionBar 自定义视图隐藏 ActionBarDrawerToggle
【发布时间】:2015-05-09 00:55:11
【问题描述】:

我在ActionBar 中有一个ActionBarDrawerToggle。我的操作栏也有一个自定义视图。绘图切换和自定义视图都出现在KitKat (4.4) API 19

但是,在较低版本(例如 4.1 API 16)上,我的操作栏中的自定义视图完全掩盖了抽屉切换。

在 4.4 (Google Nexus 5) 上运行良好:

它在 4.1 (Google Nexus 4) 上的外观(注意左侧的抽屉不见了):

想知道在这种情况下我该怎么办?有人遇到过这个问题吗?

(请注意:我没有使用actionbar sherlock,只是默认的)

谢谢!

【问题讨论】:

    标签: android android-actionbar


    【解决方案1】:

    对我有用

    getActionBar().setBackgroundDrawable(
                    new ColorDrawable(Color.parseColor("yourcolor here"))); //$NON-NLS-1$
            LayoutInflater inflator = (LayoutInflater) this
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            ActionBar actionBar = getActionBar();
            getActionBar().setDisplayShowCustomEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);
            // actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setDisplayShowHomeEnabled(false);
            // getActionBar().setIcon(R.drawable.ic_navigation_drawer);
            // navigation icon on actionbar
            actionBar.setHomeButtonEnabled(true);
            actionBar.setIcon(null);
            View actionBarView = inflator.inflate(R.layout.actionbar_custom_layout, null);
            getActionBar().setCustomView(actionBarView);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-17
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多