基于设备方向,Android Action Bar溢出不一致

发布于 2025-01-19 02:37:27 字数 543 浏览 3 评论 0原文

我有一个动作栏项目,只能显示出空间。当设备处于垂直方向时,单击有问题的屏幕时,该项目不会出现在操作栏中。将设备旋转到水平方向并不能使图标出现。菜单栏项目保留在溢出菜单中。

但是,如果我在设备处于水平方向时单击有问题的屏幕,则现在出现菜单栏项目。当将设备旋转回肖像方向时,菜单栏项目继续出现。

对于菜单栏还是溢出菜单中是否出现操作按钮,有一个不一致的经历。在垂直方向和水平方向上,显然有菜单栏项目的空间,但是似乎最初只有水平方向发送空间的信号。问题是,用户可以水平查看相同的屏幕,并且在单击屏幕上时,用户可以根据其设备的初始方向而没有菜单栏项目,从而创造出不一致的体验。我该如何解决这个问题?

这是我希望每次旋转设备时都会更新菜单栏的相关代码:

    @Override
    public void onConfigurationChanged(Configuration config) {
        super.onConfigurationChanged(config);
        supportInvalidateOptionsMenu();
    }

I have an action bar item set up to only show if there is room. When clicking onto the problematic screen when the device is in a vertical orientation, the item does not appear in the action bar. Rotating the device to a horizontal orientation does not make the icon appear as well. The menu bar item remains in the overflow menu.

However, if I click onto the problematic screen while the device is in a horizontal orientation, the menu bar item now appears. When rotating the device back to a portrait orientation, the menu bar item continues to appear.

There is an inconsistent experience on whether or not an action button appears in the menu bar or the overflow menu. There clearly is room for the menu bar item in both the vertical and horizontal orientations, however it seems that only an initially horizontal orientation sends the signal that there is room. The problem is, a user could be viewing the same screen horizontally and either have the menu bar item or not based on their device's initial orientation when clicking onto the screen, creating an inconsistent experience. How would I go about solving this?

Here is the relevant code that I would expect to update the menu bar every time the device is rotated:

    @Override
    public void onConfigurationChanged(Configuration config) {
        super.onConfigurationChanged(config);
        supportInvalidateOptionsMenu();
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文