Android的 - 如何摆脱上面的动作条了吧 [英] Android - How to get rid of the bar above the ActionBar

查看:118
本文介绍了Android的 - 如何摆脱上面的动作条了吧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:下面的Andr​​oid开发人员回答解释了解决方案非常好

Android-Developers answer below explains solution very well

我的问题是,有另一间酒吧,不完全知道它的名字是 - TitleBar中? (酒吧的菜单按钮和白色方块图案)我上面的动作条。我理想要的是合并我的动作条与条如果无法完全实现自己的酒吧,图标和菜单按钮的选项卡之间。我曾尝试几件事(见下图),以及我是如何添加标签如下所示以及粗糙code。

My problem is there are another bar, not exactly sure what it's name is - TitleBar? (The bar with the menu button and the white square logo) Above my ActionBar. What I ideally want is to merge my ActionBar with that bar or if not possible, implement my own bar completely amongst the tabs with icon and menu button. I have tried several things (see below image) and the rough code of how I am add the tabs is shown below as well.

添加标签的动作条code:

Adding tabs to the ActionBar code:

    actionBar = getActionBar();  // Get reference to ActionBar

    // Add some navigation tabs...

    // 1. Enable ActionBar navigation tabs
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

    // 2. Add the tabs
    Tab programTab = actionBar.newTab();
    Tab settingsTab = actionBar.newTab();
    Tab historyTab = actionBar.newTab();

    programTab.setText("Program")
      .setTabListener(new TabListener<Fragment_Program>(
              this, "Program", Fragment_Program.class));

    settingsTab.setText("Settings")
             .setTabListener(new TabListener<Fragment_Settings>(
                      this, "Settings", Fragment_Settings.class));

    historyTab.setText("History")
    .setTabListener(new TabListener<Fragment_History>(
              this, "History", Fragment_History.class));

    actionBar.addTab(programTab);
    actionBar.addTab(settingsTab);
    actionBar.addTab(historyTab);

我下的是IM pression getActionBar()得到参照现有的酒吧,坐在我上面的截图动作条..这将是理想的。

I was under the impression getActionBar() got reference to the existing bar which sits above my ActionBar in the screenshot.. that would be ideal.

当前应用程序的主题是安卓主题=@安卓风格/ Theme.Holo.Light.DarkActionBar

Current application theme is android:theme="@android:style/Theme.Holo.Light.DarkActionBar"

不管怎样,我已经试过如下:

Anyway, I have tried the following:

  • 各种明显的变化,包括各种.NoTitleBar组合
  • requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate()和前的setContentView()
  • Various manifest changes including various .NoTitleBar combinations
  • requestWindowFeature(Window.FEATURE_NO_TITLE); after super.onCreate() and before setContentView()

我使用的标准动作条的原因是本作将运行至少4.0的硬件设备和版本是极不可能改变。

The reason I am using standard ActionBar is this for a hardware device that will be running at least 4.0 and the version is highly unlikely to change.

有什么想法?

干杯

推荐答案

正如我能理解你要删除这个观点对不对?

As I can understand you want to remove that view right?

的问题是,它的动作条。我猜你想使用标签,但没有像很多都是这样做的应用程序的动作条。要实现这一点:

The problem is that it your ActionBar. I guess you want to use Tabs, but without the ActionBar like many of the apps which are doing that. To achieve this use :

bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowTitleEnabled(false);
bar.setDisplayShowHomeEnabled(false);

但不要忘了的东西,如果你想做到这一点,你不应该夸大任何菜单中的片段/活动:

But don't forget something, if you want to achieve this, you should not inflate any menu in your Fragment / Activity :

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //getSupportMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

这篇关于Android的 - 如何摆脱上面的动作条了吧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆