【发布时间】:2014-06-02 16:49:51
【问题描述】:
我正在尝试显示从官方 android 开发者源下载的地图图标。
我做了所有应该做的事情,但图标不会显示。
这是我名为main_activity_bar的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/mapIcon"
android:icon="@drawable/ic_action_map"
android:title="@string/mapIconTitle"
android:showAsAction="always"
/>
</menu>
这里是主要活动 xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.gs.testApp.MainActivity"
tools:ignore="MergeRootFrame" />
这就是我在 java 类中所拥有的:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater actionMenue = getMenuInflater();
actionMenue.inflate(R.menu.main_activity_bar, menu);
return super.onCreateOptionsMenu(menu);
}
一切似乎都很好,但图标不会显示在模拟器上。截图如下:
最低版本为android 3.0
为什么图标没有显示?我错过了什么?我知道它是非常小的东西,但我无法发现它。
【问题讨论】:
-
单击 3 点溢出菜单图标以查看操作栏图标。如果没有足够的空间,它将在溢出菜单中看到
-
@Raghunandan 当我单击 3 个点时,我只能看到标题
test。在上面的屏幕截图中,它已经被点击了。 -
stackoverflow.com/questions/5216603/…。 Quotng Romain Nurik “图标未显示在操作栏的溢出菜单中的行为是设计使然”
标签: java android xml android-activity android-actionbar