【问题标题】:ActionBarSherlock + split action bar menu + items with "withText" doesn't show text. How to fix?ActionBarSherlock + 拆分操作栏菜单 + 带有“withText”的项目不显示文本。怎么修?
【发布时间】:2012-11-14 23:49:38
【问题描述】:

我正在使用 ActionBarSherlock,我正在尝试向 ActionBar 添加一个选项菜单。

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/menu_prev"
        android:title="@string/menu_previous"
        android:icon="@drawable/left_navigation"
        android:showAsAction="always|withText" />

    <item android:id="@+id/menu_next"
        android:title="@string/menu_next"
        android:icon="@drawable/right_navigation"
        android:showAsAction="always|withText" />

</menu>

drawable-mdpi 目录中的图标为 32x32 像素。当 ActionBar 被拆分(纵向)时,图标显示但没有文本显示(虽然空间很大)。长按图标 祝标题。当 ActionBar 未拆分(横向)时,图标和文本都按预期显示。

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    return super.onCreateOptionsMenu(menu);
}

Menu、MenuInflater 和 getSupportMenuInflater() 都使用 ActionBarSherlock 实现。

清单中的“应用程序”声明:

android:uiOptions="splitActionBarWhenNarrow"

如何使它在纵向时显示每个项目的标题?

编辑:可能相关的是我正在运行 Android 4.0.4。

【问题讨论】:

  • AFAIK,withText 是对 ABS 和本机操作栏的请求,而不是命令。

标签: android actionbarsherlock


【解决方案1】:

如果您使用的是 Android >= 3.0 ABS 使用操作栏的系统实现,因此您看到的行为是正确的。请参阅@CommonsWare 对问题的评论,了解为什么会出现这种行为。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多