繁体   English   中英

ActionBar菜单图标仅显示在溢出菜单上

[英]ActionBar Menu icons only shows on overflow menu

我目前在操作栏上显示选项菜单项时遇到问题。 由于某些原因,这些项目仅显示在溢出菜单上,这对于后ICS设备也是如此。 我正在使用v7-appcompat库来支持从版本8开始的SDK。

在主要活动中,我有:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.wild_news, menu);
    return true;
}

我的菜单项定义如下:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      **xmlns:app="http://schemas.android.com/apk/res-auto"** >

  <item
    android:id="@+id/menu_refresh"
    android:icon="@drawable/ic_action_refresh"
    **app:showAsAction="always"**
    android:title="@string/menuTitle_refresh"/>
<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    **app:showAsAction="ifRoom"**
    android:title="@string/action_settings"/>

我在动作栏中也有一个带有以下xml布局的微调框:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:minHeight="50dp"
       android:minWidth="140dp"
       android:layout_gravity="center_vertical"
       style="@style/ActionBarNavListTitle" />

我似乎无法解决这个问题。

太好了,我发现此问题与我现在已解决的ActionBar样式定义不匹配有关:

<style name="ActionBarStyle"   parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM