Android隐藏Actionbar仅显示选项卡

时间:2016-01-11 19:52:55

标签: android tabs android-actionbar appbar

我想在顶部显示标签,并隐藏操作栏。

Only the parts in the red rectangle, and hide the empty row above them.

我使用这些行来隐藏图标,以及操作栏上的标题:

    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowHomeEnabled(false);

有什么建议可以只在我的应用中添加标签吗?

2 个答案:

答案 0 :(得分:1)

如果要在代码中隐藏它。您可能还需要删除正在使用它的onCreateOptionsMenu(例如)。

public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
}

还在创建中添加以下行。

getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().hide();

答案 1 :(得分:0)

清单

android:theme="@style/Theme.AppCompat.NoActionBar"
相关问题