为什么在动作条的上面有我的溢流下拉菜单?我的、菜单、动作

2023-09-12 01:34:43 作者:本尊~、独爱

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

  @覆盖
公共布尔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 =从不/>
< /菜单>
 

解决方案

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

  Excel数据有效性设置的下拉菜单内容有多个,但选择时只能单选,如何设置下拉菜单,可以在选择时多选

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

这是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.

 
精彩推荐
图片推荐