gpt4 book ai didi

android - 根据 Material 设计规范创建 "Simple Menu"

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:15:53 28 4
gpt4 key购买 nike

根据这个http://www.google.com/design/spec/components/menus.html#menus-simple-menus ,第一个菜单项与原始行的垂直中心对齐,如下所示: first popup menu vertically aligns with item

我正在尝试为 ListView 项目创建此菜单,如下所示:

@Override
public void onListItemClick(ListView l, View v, final int position, long id) {
PopupMenu popup = new PopupMenu(getContext(), v, Gravity.CENTER_HORIZONTAL);
popup.getMenuInflater().inflate(R.menu.bus_line_popup, popup.getMenu());
popup.setOnMenuItemClickListener(...);
popup.show();
}

然而,菜单并没有按照规范正确显示: popup menu does not appear centered

如何使菜单完全按要求显示?

最佳答案

我做了一点搜索,请参阅:http://developer.android.com/reference/android/widget/PopupMenu.html

A PopupMenu displays a Menu in a modal popup window anchored to a View. The popup will appear below the anchor view if there is room, or above it if there is not. If the IME is visible the popup will not overlap it until it is touched. Touching outside of the popup will dismiss it.

作为doc说,这似乎是正常的当有空间时,它会显示在 View 下方(像你的情况),如果没有roow,它将显示在 View 上方

关于android - 根据 Material 设计规范创建 "Simple Menu",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35157046/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com