为什么仅显示2菜单图标的动作条即使有足够的空间3' [英] why it only show 2 menu icon on the actionbar even though there are enough space for 3?

查看:109
本文介绍了为什么仅显示2菜单图标的动作条即使有足够的空间3'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在菜单栏上3菜单图标,但每次只显示2个图标,最后一个是行不通的。
我的问题是:
1.有3个图标,为什么只有2中显示出足够的空间?
2.如果系统认为空间是不够的第三图标,为什么没有结合的第二和第三个图标到溢出菜单?

下面是我menu.xml文件

 <?XML版本=1.0编码=UTF-8&GT?;
<菜单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>    <项目机器人:ID =@ + ID /刷新
          机器人:图标=@绘制/ ic_menu_refresh
          机器人:showAsAction =ifRoom/>
    <项目机器人:ID =@ + ID / add_homework
          机器人:图标=@机器人:可绘制/ ic_menu_edit
          机器人:showAsAction =ifRoom/>
    <项目机器人:ID =@ + ID / set_groupid
          机器人:图标=@机器人:可绘制/ ic_menu_ preferences
          机器人:showAsAction =ifRoom/>
&所述; /菜单>

这个片段是在我MainActivity

  @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){
    。getMenuInflater()膨胀(R.menu.menu,菜单);
    返回super.onCreateOptionsMenu(菜单);}


解决方案

  

我在菜单栏上3菜单图标


有关这个答案的目的,我假设,通过菜单栏您指的是行动起来吧。


  

但每次只显示2个图标,最后一个是在无处


最后一个可通过pressing MENU按钮,对具有一个离屏MENU按钮设备(或模拟器)。


  

有足够的空间让3个图标,为什么只有2中显示?


presumably由于Android不同意你的是否有对3个图标足够的空间评估。


  

如果系统认为空间是不够的第三图标,为什么没有第二和第三个图标合并成一个溢出菜单?


我不知道为什么你认为迫使第二个图标 - 这,你的入场,适合 - 到溢出菜单将是一个不错的主意。第三菜单项在溢出菜单,这是通过对具有一个设备上的MENU按钮或三个垂直点按钮的动作条上的缺少菜单按钮的设备。

I have 3 menu icons on the menu bar, but everytime it only shows 2 icons, the last one is in nowhere. my questions are: 1. there is enough space for 3 icons, why only 2 are shown? 2. if the system thinks the space is not enough for the 3rd icon, why doesn't it combine the 2nd and 3rd icon into an overflow menu?

Below is my menu.xml

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



    <item android:id="@+id/refresh"
          android:icon="@drawable/ic_menu_refresh"
          android:showAsAction="ifRoom" />        
    <item android:id="@+id/add_homework"
          android:icon="@android:drawable/ic_menu_edit"
          android:showAsAction="ifRoom" />    
    <item android:id="@+id/set_groupid"
          android:icon="@android:drawable/ic_menu_preferences"
          android:showAsAction="ifRoom" /> 


</menu>

and this snippet is in my MainActivity

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);
    return super.onCreateOptionsMenu(menu);

}

解决方案

I have 3 menu icons on the menu bar

For the purposes of this answer, I am assuming that by "menu bar" you are referring to the action bar.

but everytime it only shows 2 icons, the last one is in nowhere

The last one is available by pressing the MENU button, for devices (or emulators) that have an off-screen MENU button.

there is enough space for 3 icons, why only 2 are shown?

Presumably because Android disagrees with your assessment of whether or not there is enough space for 3 icons.

if the system thinks the space is not enough for the 3rd icon, why doesn't it combine the 2nd and 3rd icon into an overflow menu?

I have no idea why you think forcing the 2nd icon -- which, by your admission, fits -- into the overflow menu would be a good idea. The 3rd menu item is in the overflow menu, which is accessed via the MENU button on devices that have one or a three-vertical-dots button on the action bar for devices that lack a MENU button.

这篇关于为什么仅显示2菜单图标的动作条即使有足够的空间3'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆