主题分层代号

时间:2017-04-26 14:40:51

标签: java codenameone

主题分层:我已经按照步骤给出了什么问题,但分层不起作用。我已将purenativetheme常量更改为false。

private Form current;
private Resources theme;

public void init(Object context) {
    theme = UIManager.initFirstTheme("/theme");
    UIManager.getInstance().addThemeProps(theme.getTheme("Theme"));
    // Enable Toolbar on all Forms by default
    Toolbar.setGlobalToolbar(true);

    // Pro only feature, uncomment if you have a pro subscription
    // Log.bindCrashProtection(true);
}

public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Welcome", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
    final Label apple = new Label(theme.getImage("apple-icon.png")); 
    final Label android = new Label(theme.getImage("android-icon.png")); 
    final Label windows = new Label(theme.getImage("windows-icon.png")); 
    Button getStarted = new Button("Let's Get Started!");
    getStarted.setUIID("Button");
    FontImage.setMaterialIcon(getStarted, FontImage.MATERIAL_LINK);
    getStarted.setUIID("GetStarted");
    hi.addComponent(BorderLayout.CENTER, 
            LayeredLayout.encloseIn(
                    BoxLayout.encloseY(
                            new Label(theme.getImage("duke-no-logos.png")),
                            getStarted
                    ),
                    FlowLayout.encloseRightMiddle(apple)
                )
    );

    getStarted.addActionListener((e) -> {
        Display.getInstance().execute("https://www.codenameone.com/developers.html");
    });

    new UITimer(() -> {
        if(apple.getParent() != null) {
            apple.getParent().replace(apple, android, CommonTransitions.createFade(500));
        } else {
            if(android.getParent() != null) {
                android.getParent().replace(android, windows, CommonTransitions.createFade(500));
            } else {
                windows.getParent().replace(windows, apple, CommonTransitions.createFade(500));
            }                
        }
    }).schedule(2200, true, hi);
    hi.show();
}

0 个答案:

没有答案