android - 类似 evernote 的操作栏 - 向上按钮和选项卡在顶部的一行中,菜单操作在底部

标签 android android-layout android-actionbar actionbarsherlock

我有一个应用程序,它的操作栏包含 1)向上按钮打开侧边栏导航菜单就像谷歌加 2) 2个操作菜单按钮 3) 2个标签通过view pager实现

我已经使用 actionbarsherlock 成功实现了 actionbar,结果是 -> enter image description here

enter image description here

我想实现类似 evernote 应用程序的东西,其中向上按钮和选项卡在一行中,操作菜单使用 split actionbar 。我有标签图标,所以将它们与向上按钮排成一行不是问题

有人可以给我指出正确的方向,关于如何通过修改 actionbarsherlock lib 使向上按钮与选项卡位于同一水平栏中。

谢谢

最佳答案

//启用嵌入式标签

//pre-ICS
if (actionBarSherlock instanceof ActionBarImpl) {
    enableEmbeddedTabs(actionBarSherlock);

//ICS and forward
} else if (actionBarSherlock instanceof ActionBarWrapper) {
    try {
        Field actionBarField = actionBarSherlock.getClass().getDeclaredField("mActionBar");
        actionBarField.setAccessible(true);
        enableEmbeddedTabs(actionBarField.get(actionBarSherlock));
    } catch (Exception e) {
        Log.e(TAG, "Error enabling embedded tabs", e);
    }
}

//helper method
private void enableEmbeddedTabs(Object actionBar) {
    try {
        Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class);
        setHasEmbeddedTabsMethod.setAccessible(true);
        setHasEmbeddedTabsMethod.invoke(actionBar, true);
    } catch (Exception e) {
        Log.e(TAG, "Error marking actionbar embedded", e);
    }
}

进一步引用 - https://groups.google.com/forum/#!topic/actionbarsherlock/hmmB1JqDeCk

关于android - 类似 evernote 的操作栏 - 向上按钮和选项卡在顶部的一行中,菜单操作在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12761218/

相关文章:

android - 给定运行设备的像素密度和 API 版本,Android 将如何选择正确的资源?

android - TextView 不粘在右上角

android - 创建安卓帮助屏幕

android - appcompat 中带有 ActionBar 的自定义布局导致内容与操作栏重叠

android - 用 MonkeyRunner 切换屏幕模式?

Android 10 MediaStore API 更改

android - 如何使用 ADB Sideload 镜像手机屏幕?

java - Android:将墙纸更改为可绘制

android - 将工具栏用作操作栏时如何设置 SearchView 的样式?

android - 如何更改操作栏文本和背景属性?