【发布时间】:2016-09-01 23:57:03
【问题描述】:
在 Codename One 中,我有一个类似 UI 的简单聊天,并希望使用 animateLayout 添加消息(标签)。如果消息之间有时间或者动画时间很短,它可以正常工作,但是当两个动画重叠时,第二个组件没有动画。这是我尝试过的代码(把它放在新的代号一个项目启动方法中):
Form hi = new Form("Hi World");
hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
Button button = new Button("Add");
Label label = new Label("Status");
button.addActionListener((actionEvent) -> {
hi.getContentPane().add("asd");
hi.getContentPane().animateLayout(3000);
});
hi.add(button);
hi.show();
我希望将 animateLayout 更改为 animateLayoutAndWait 会解决这个问题,但它没有。我也尝试了旧的解决方法:
Form hi = new Form("Hi World");
hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
Button button = new Button("Add");
Label label = new Label("Status");
button.addActionListener((actionEvent) -> {
if(!animateLock) {
animateLock = true;
hi.getContentPane().add("asd");
hi.getContentPane().animateLayout(3000);
animateLock = false;
}
});
hi.add(button);
hi.show();
其中 animateLock 是主类的一个字段。我还尝试将添加包装在 Display.getInstance().callSerially(() -> {code here}) 中,但它也不起作用。 如何处理并发动画?
【问题讨论】:
标签: codenameone