android - Actionbarsherlock 中的选项卡总是在操作栏内?

标签 android actionbarsherlock

我正在运行 Actionbersherlock 示例中的演示,并注意到选项卡始终位于操作栏内,如图所示。我该如何解决? 谢谢。

enter image description here

public class TabNavigation extends SherlockActivity implements ActionBar.TabListener {
private TextView mSelected;

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(SampleList.THEME); //Used for theme switching in samples
    super.onCreate(savedInstanceState);

    setContentView(R.layout.tab_navigation);
    mSelected = (TextView)findViewById(R.id.text);

    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    for (int i = 1; i <= 3; i++) {
        ActionBar.Tab tab = getSupportActionBar().newTab();
        tab.setText("Tab " + i);
        tab.setTabListener(this);
        getSupportActionBar().addTab(tab);
    }
}

@Override
public void onTabReselected(Tab tab, FragmentTransaction transaction) {
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction transaction) {
    mSelected.setText("Selected: " + tab.getText());
}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction transaction) {
}

代码来自这里:

https://github.com/JakeWharton/ActionBarSherlock/blob/master/actionbarsherlock-samples/demos/src/com/actionbarsherlock/sample/demos/TabNavigation.java

最佳答案

根据 Action Bar Tabs guide :

the system adapts the action bar tabs for different screen sizes—placing them in the main action bar when the screen is sufficiently wide, or in a separate bar (known as the "stacked action bar") when the screen is too narrow

由于 ActionBarSherlock 模仿平台行为,如果有足够的空间,选项卡将出现在操作栏中。您不能按照 other 强制堆叠操作栏模式answers .

关于android - Actionbarsherlock 中的选项卡总是在操作栏内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16863594/

相关文章:

android - 是否可以扩展 AbsListView 以进行新的 ListView 实现?

android - 如何在 Activity 中使用 Room 和 LiveData 删除 LiveData<Object>?

android - 如何更改 android 中 sherlock actionbar overflow-dropdown 项目的文本颜色?

android - 在 Android ActionBar 上访问 ActionView

android - 如何在 ActionBar 的溢出菜单中显示图标

android - 操作栏显示在其选项卡下方

android - 检测内部存储器?

android - 将可绘制图像附加到android中的电子邮件

android - 升级 Android Studio 2.3 后数据绑定(bind)不起作用

android - ActionBarSherlock:在极少数设备上出现 java.lang.IllegalStateException