iPad上的Codenameone App在睡眠开始时每次使用错误的长宽比

时间:2019-03-10 15:41:48

标签: java ios codenameone

首先,我是codenameone的新手,所以对不起,如果解决方案很明显,我感到抱歉。 我有一个问题,我的codenameone应用程序从后台启动后确实会调整当前表单的大小,但仅在iPad上。它只会执行其他所有恢复,因此一次正常,背景,调整大小的格式,背景,正常。

在模拟器和iPhone上,行为正常,只是iPad被弄乱了。

有人可以指出我的方向吗?我认为某些东西可能会被调用两次,但我不知道是什么... onstart()和onStop()以及代码的代码示例已附加。.

谢谢!

rgds Vinc

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Controller.showSplash(); // go to splash screen. Splash screen forwards to mainMenu();
}

public void stop() {
    current = getCurrentForm();
    if (current instanceof Dialog) {
        ((Dialog) current).dispose();
        current = getCurrentForm();
    }
}

// Gui Builder代码

public MainMenu(com.codename1.ui.util.Resources resourceObjectInstance) {
    initGuiBuilderComponents(resourceObjectInstance);
}

protected com.codename1.ui.Label gui_Label = new com.codename1.ui.Label();
protected com.codename1.ui.Container gui_Box_Layout_Y = new com.codename1.ui.Container(new com.codename1.ui.layouts.GridLayout(1, 1));
protected com.codename1.components.ScaleImageButton gui_Scaled_Button = new com.codename1.components.ScaleImageButton();
protected com.codename1.components.ScaleImageButton gui_Scaled_Button_1 = new com.codename1.components.ScaleImageButton();
protected com.codename1.components.ScaleImageButton gui_Scaled_Button_2 = new com.codename1.components.ScaleImageButton();
protected com.codename1.ui.Label gui_Label_1 = new com.codename1.ui.Label();
protected com.codename1.ui.Button gui_Button = new com.codename1.ui.Button();

private void guiBuilderBindComponentListeners() {
    EventCallbackClass callback = new EventCallbackClass();
    gui_Scaled_Button.addActionListener(callback);
    gui_Scaled_Button_1.addActionListener(callback);
    gui_Scaled_Button_2.addActionListener(callback);
    gui_Button.addActionListener(callback);
}

class EventCallbackClass implements com.codename1.ui.events.ActionListener, com.codename1.ui.events.DataChangedListener {
    private com.codename1.ui.Component cmp;
    public EventCallbackClass(com.codename1.ui.Component cmp) {
        this.cmp = cmp;
    }

    public EventCallbackClass() {
    }

    public void actionPerformed(com.codename1.ui.events.ActionEvent ev) {
        com.codename1.ui.Component sourceComponent = ev.getComponent();

        if(sourceComponent.getParent().getLeadParent() != null && (sourceComponent.getParent().getLeadParent() instanceof com.codename1.components.MultiButton || sourceComponent.getParent().getLeadParent() instanceof com.codename1.components.SpanButton)) {
            sourceComponent = sourceComponent.getParent().getLeadParent();
        }

        if(sourceComponent == gui_Scaled_Button) {
            onScaled_ButtonActionEvent(ev);
        }
        if(sourceComponent == gui_Scaled_Button_1) {
            onScaled_Button_1ActionEvent(ev);
        }
        if(sourceComponent == gui_Scaled_Button_2) {
            onScaled_Button_2ActionEvent(ev);
        }
        if(sourceComponent == gui_Button) {
            onButtonActionEvent(ev);
        }
    }

    public void dataChanged(int type, int index) {
    }
}
private void initGuiBuilderComponents(com.codename1.ui.util.Resources resourceObjectInstance) {
    guiBuilderBindComponentListeners();
    setLayout(new com.codename1.ui.layouts.LayeredLayout());
    setInlineStylesTheme(resourceObjectInstance);
    setScrollableX(false);
    setScrollableY(false);
            setInlineStylesTheme(resourceObjectInstance);
    setInlineAllStyles("fgColor:ffffff; opacity:220;");
    setTitle("");
    setName("ToolBox");
    ((com.codename1.ui.layouts.LayeredLayout)getLayout()).setPreferredWidthMM((float)156.8586);
    ((com.codename1.ui.layouts.LayeredLayout)getLayout()).setPreferredHeightMM((float)171.04149);
    addComponent(gui_Label);
    addComponent(gui_Box_Layout_Y);
    gui_Box_Layout_Y.setPreferredSizeStr("64.9873mm 52.921253mm");
            gui_Box_Layout_Y.setInlineStylesTheme(resourceObjectInstance);
    gui_Box_Layout_Y.setName("Box_Layout_Y");
    ((com.codename1.ui.layouts.LayeredLayout)gui_Box_Layout_Y.getParent().getLayout()).setInsets(gui_Box_Layout_Y, "24.82299% auto 28.533901% auto").setReferenceComponents(gui_Box_Layout_Y, "-1 -1 0 -1").setReferencePositions(gui_Box_Layout_Y, "0.0 0.0 1.0 0.0");
    gui_Box_Layout_Y.addComponent(gui_Scaled_Button);
    gui_Box_Layout_Y.addComponent(gui_Scaled_Button_1);
    gui_Box_Layout_Y.addComponent(gui_Scaled_Button_2);
            gui_Scaled_Button.setInlineStylesTheme(resourceObjectInstance);
    gui_Scaled_Button.setName("Scaled_Button");
    gui_Scaled_Button.setIcon(resourceObjectInstance.getImage("CrewRest_V02.jpg"));
            gui_Scaled_Button_1.setInlineStylesTheme(resourceObjectInstance);
    gui_Scaled_Button_1.setName("Scaled_Button_1");
    gui_Scaled_Button_1.setIcon(resourceObjectInstance.getImage("Fuel_V02.jpg"));
            gui_Scaled_Button_2.setInlineStylesTheme(resourceObjectInstance);
    gui_Scaled_Button_2.setName("Scaled_Button_2");
    gui_Scaled_Button_2.setIcon(resourceObjectInstance.getImage("Snowtam_V02.jpg"));
    addComponent(gui_Label_1);
    addComponent(gui_Button);
    gui_Label.setPreferredSizeStr("182.2608mm 10.0mm");
    gui_Label.setUIID("LabelGrey");
            gui_Label.setInlineStylesTheme(resourceObjectInstance);
    gui_Label.setInlineAllStyles("bgColor:5f6a6d; transparency:255; opacity:255; margin:0.0mm 0.0mm 0.0mm 0.0mm;");
    gui_Label.setName("Label");
    ((com.codename1.ui.layouts.LayeredLayout)gui_Label.getParent().getLayout()).setInsets(gui_Label, "92.31431% 0.0mm 0.0mm 0.0mm").setReferenceComponents(gui_Label, "-1 -1 -1 -1").setReferencePositions(gui_Label, "0.0 0.0 0.0 0.0");
    gui_Box_Layout_Y.setPreferredSizeStr("64.9873mm 52.921253mm");
            gui_Box_Layout_Y.setInlineStylesTheme(resourceObjectInstance);
    gui_Box_Layout_Y.setName("Box_Layout_Y");
    ((com.codename1.ui.layouts.LayeredLayout)gui_Box_Layout_Y.getParent().getLayout()).setInsets(gui_Box_Layout_Y, "24.82299% auto 28.533901% auto").setReferenceComponents(gui_Box_Layout_Y, "-1 -1 0 -1").setReferencePositions(gui_Box_Layout_Y, "0.0 0.0 1.0 0.0");
            gui_Label_1.setInlineStylesTheme(resourceObjectInstance);
    gui_Label_1.setInlineAllStyles("bgColor:ffffff; transparency:255;");
    gui_Label_1.setName("Label_1");
    gui_Label_1.setIcon(resourceObjectInstance.getImage("AeroLogic_Logo.jpg"));
    ((com.codename1.ui.layouts.LayeredLayout)gui_Label_1.getParent().getLayout()).setInsets(gui_Label_1, "0.0mm auto auto auto").setReferenceComponents(gui_Label_1, "-1 -1 -1 -1").setReferencePositions(gui_Label_1, "0.0 0.0 0.0 0.0");
    gui_Button.setPreferredSizeStr("7.1972904mm 4.022015mm");
    gui_Button.setUIID("ButtonInfo");
            gui_Button.setInlineStylesTheme(resourceObjectInstance);
    gui_Button.setInlineAllStyles("fgColor:ffffff;");
    gui_Button.setName("Button");
    com.codename1.ui.FontImage.setMaterialIcon(gui_Button,"\ue88e".charAt(0));
    ((com.codename1.ui.layouts.LayeredLayout)gui_Button.getParent().getLayout()).setInsets(gui_Button, "auto 2.3285353mm auto auto").setReferenceComponents(gui_Button, "0 0 0 -1").setReferencePositions(gui_Button, "0.0 0.0 0.0 0.0");
}// </editor-fold>

After resume

Normal after every second resume

0 个答案:

没有答案