为什么在动作条的上面有我的溢流下拉菜单? [英] Why is my overflow dropdown menu on top of the actionbar?

查看:129
本文介绍了为什么在动作条的上面有我的溢流下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下是不是应该是动作条下?所以我在做什么错了?

  @覆盖
公共布尔onCreateOptionsMenu(功能菜单){
    //充气菜单;这增加了项目操作栏,如果它是present。
    。getMenuInflater()膨胀(R.menu.main,菜单);
    返回true;
}
 

RES /菜单/ main.xml中

 <菜单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
的xmlns:工具=htt​​p://schemas.android.com/tool​​s
工具:上下文=com.example.test.MainActivity>

<项目
    机器人:ID =@ + ID / action_settings
    机器人:orderInCategory =100
    机器人:标题=@字符串/ action_settings
    应用程序:showAsAction =从不/>
< /菜单>
 

解决方案

根据该的材质设计规范,溢出菜单应显示在操作栏的顶部:

  

一个菜单是一张临时表总是重叠的应用栏,而不是表现为应用栏的扩展。

这是Android棒棒糖应用以及使用该AppCompat V7支持库的任何应用程序的默认行为。

By default isn't it supposed to be under the actionbar? So what am I doing wrong?

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

res/menu/main.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.test.MainActivity" >

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:title="@string/action_settings"
    app:showAsAction="never"/>
</menu>

解决方案

According to the Material Design specifications, the overflow menu should display on top of the action bar:

A menu is a temporary sheet of paper that always overlaps the app bar, rather than behaving as an extension of the app bar.

This is the default behavior for Android Lollipop applications as well as any applications that use the AppCompat v7 support library.

这篇关于为什么在动作条的上面有我的溢流下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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