首页 文章

iPhone 6:InteractionDiaog显得太过分了;内容隐藏

提问于
浏览
2

我正在尝试在Codename One应用程序中实现聊天功能,基本上使用教程示例“Building a Chat App with Codename One” . 部分原因是当有人试图与您联系时,会出现InteractionDialog . 这在模拟器和我的Android设备上看起来很好,但在iPhone 6上,对话框似乎绘制得太远,导致只有 Headers 可见 .

这是程序代码:

int h = toast.getPreferredH();
    int dh = Display.getInstance().getDisplayHeight(); // just for debugging
    toast.show(Display.getInstance().getDisplayHeight() - h - 10, 10, 10, 10);
    UITimer uit = new UITimer(() -> {
        toast.dispose();
    });

吐司高度,显示高度:
模拟器:h = 221,dh = 480
Android:h = 359,dh = 1674
iPhone 6:h = 304,dh = 1334(这个太靠近底部了)

屏幕指标有问题吗,我该怎么做才能解决这个问题?我以前在InteractionDialog的位置上遇到过其他一些类似的问题 .

我很乐意展示一些截图,但我还不能发布那么多链接 .

1 回答

  • 2

    我认为聊天应用程序的代码可能有点不对,请改变这个:

    int h = toast.getPreferredH();
    int dh = Display.getInstance().getDisplayHeight(); // just for debugging
    toast.show(Display.getInstance().getDisplayHeight() - h - 10, 10, 10, 10);
    

    对此:

    int h = toast.getPreferredH();
    int dh = Display.getCurrent().getContentPane().getHeight();
    toast.show(dh - h - 10, 10, 10, 10);
    

    分层窗格(InteractionDialog所在的位置)位于内容窗格区域的顶部,而不是整个显示高度,因此不考虑 Headers 区域/状态栏区域 .

    在即将推出的版本中,我们将有新的ToastBar component .

相关问题