淡化动画无效。串行呼叫也不起作用。如果我只添加一个组件来淡化,问题仍然存在。这是关于它在模拟器中的外观的视频。
https://www.youtube.com/watch?v=mMyhUC6m9Vk
public class QuizSplash {
private Form current;
private Resources theme;
Label bb;
Label appleLabel;
Label whiteBgLabel;
Image whiteBg;
Image apple;
int deviceHeight;
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
deviceHeight = Display.getInstance().getDisplayHeight();
whiteBg = (Image) theme.getImage("whiteBg.png");
apple = (Image) theme.getImage("apple.png").scaledWidth(deviceHeight / 5);
}
public void start() {
if (current != null) {
current.show();
return;
}
showSplashAnimation();
}
public void showSplashAnimation() {
Form f = new Form(new LayeredLayout());
f.setUIID("FormAnimation");
f.getAllStyles().setBgColor(0x339900);
f.getAllStyles().setBgTransparency(255);
whiteBgLabel = new Label(whiteBg.scaledHeight(deviceHeight - 80));
whiteBgLabel.setUIID("treeLabel");
whiteBgLabel.getAllStyles().setBgColor(0xffffff);
f.add(FlowLayout.encloseCenter(whiteBgLabel));
whiteBgLabel.setVisible(false);
Container bottomContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
bottomContainer.setUIID("bottomContainer");
bottomContainer.getAllStyles().setPadding(Component.LEFT, 40);
f.add(FlowLayout.encloseBottom(bottomContainer));
Container appleContainer = new Container(new FlowLayout(Component.CENTER, Component.BOTTOM));
appleLabel = new Label(apple);
appleLabel.setUIID("apple");
appleLabel.getAllStyles().setPadding(0, 0, 0, 0);
appleLabel.getAllStyles().setMargin(0, 0, 0, 0);
appleContainer.add(appleLabel);
bottomContainer.add(appleContainer);
appleLabel.setVisible(false);
bb = new Label(apple);
bb.setVisible(false);
bottomContainer.add(bb);
//text container to fade in at last - update added starts.........................
quizContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
f.add(FlowLayout.encloseIn(quizContainer));
TextArea question = new TextArea("Here is the question?");
question.setVisible(false);
question.setUIID("Label");
question.setEditable(false);
question.setGrowByContent(true);
question.setGrowLimit(3);
quizContainer.add(question);
Container ansContainer = new Container(new FlowLayout(Component.CENTER));
quizContainer.add(ansContainer);
Label yes = new Label("YES");
yes.setVisible(false);
Label no = new Label("No");
no.setVisible(false);
ansContainer.add(yes);
ansContainer.add(no);
//update added ends.........................
f.show();
bb.setX(-bb.getWidth());
bb.setVisible(true);
bb.getParent().animateHierarchyAndWait(2500);
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
appleLabel.setVisible(true);
appleContainer.animateHierarchyFadeAndWait(2000, 0);
whiteBgLabel.setVisible(true);
whiteBgLabel.getParent().animateLayoutFadeAndWait(3000, 0);
//update added starts...............
question.setVisible(true);
yes.setVisible(true);
no.setVisible(true);
quizContainer.animateLayoutFadeAndWait(2000, 0);
//update added ends...........
}
});
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
}
更新1: 下面的代码在模拟器中工作,但在实际设备中苹果组件淡入是好的,其他有相同的问题。
bb.setX(-bb.getWidth());
bb.setVisible(true);
bb.getParent().animateHierarchyAndWait(2500);
Display.getInstance().callSerially(() -> {
Display.getInstance().callSerially(() -> {
appleLabel.setVisible(true);
appleContainer.animateHierarchyFadeAndWait(2000, 0);
Display.getInstance().callSerially(() -> {
whiteBgLabel.setVisible(true);
whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0);
Display.getInstance().callSerially(() -> {
question.setVisible(true);
yes.setVisible(true);
no.setVisible(true);
quizContainer.animateLayoutFadeAndWait(2000, 0);
});
});
});
});
更新2: 以下代码在模拟器和设备中都不起作用
bb.setX(-bb.getWidth());
bb.setVisible(true);
bb.getParent().animateHierarchyAndWait(2500);
Display.getInstance().callSerially(() -> {
appleLabel.setVisible(true);
appleContainer.animateHierarchyFadeAndWait(2000, 0);
});
Display.getInstance().callSerially(() -> {
whiteBgLabel.setVisible(true);
whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0);
});
Display.getInstance().callSerially(() -> {
question.setVisible(true);
yes.setVisible(true);
no.setVisible(true);
quizContainer.animateLayoutFadeAndWait(2000, 0);
});
UPDATE3: 用flushAnimation串行替换调用在模拟器和设备中不起作用
bb.setX(-bb.getWidth());
bb.setVisible(true);
bb.getParent().animateHierarchyAndWait(2500);
Display.getInstance().callSerially(() -> {
Display.getInstance().callSerially(() -> {
appleLabel.setVisible(true);
appleContainer.animateHierarchyFadeAndWait(2000, 0);
f.getAnimationManager().flushAnimation(() -> {
whiteBgLabel.setVisible(true);
whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0);
f.getAnimationManager().flushAnimation(() -> {
question.setVisible(true);
yes.setVisible(true);
no.setVisible(true);
quizContainer.animateLayoutFadeAndWait(2000, 0);
});
});
});
});
在呼叫中串行添加flush动画在设备中不起作用
bb.setX(-bb.getWidth());
bb.setVisible(true);
bb.getParent().animateHierarchyAndWait(2500);
Display.getInstance().callSerially(() -> {
Display.getInstance().callSerially(() -> {
appleLabel.setVisible(true);
appleContainer.animateHierarchyFadeAndWait(2000, 0);
Display.getInstance().callSerially(() -> {
f.getAnimationManager().flushAnimation(() -> {
whiteBgLabel.setVisible(true);
whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0);
f.getAnimationManager().flushAnimation(() -> {
question.setVisible(true);
yes.setVisible(true);
no.setVisible(true);
quizContainer.animateLayoutFadeAndWait(2000, 0);
});
});
});
});
});
更新4:
Form f = new Form(new BoxLayout(BoxLayout.Y_AXIS));
Label a = new Label(apple);
Label b = new Label(apple);
Label c = new Label(apple);
Label d = new Label(apple);
a.setVisible(false);
b.setVisible(false);
c.setVisible(false);
d.setVisible(false);
f.add(FlowLayout.encloseCenter(a));
f.add(FlowLayout.encloseCenter(b));
f.add(FlowLayout.encloseCenter(c));
f.add(FlowLayout.encloseCenter(d));
f.show();
a.setVisible(true);
a.getParent().animateLayoutFadeAndWait(2000, 0);
Display.getInstance().callSerially(() -> {
Display.getInstance().callSerially(() -> {
b.setVisible(true);
b.getParent().animateLayoutFadeAndWait(2000, 0);
f.getAnimationManager().flushAnimation(() -> {
Display.getInstance().callSerially(() -> {
c.setVisible(true);
c.getParent().animateLayoutFadeAndWait(2000, 0);
Display.getInstance().callSerially(() -> {
d.setVisible(true);
d.getParent().animateLayoutFadeAndWait(2000, 0);
});
});
});
});
});
答案 0 :(得分:0)
这对我来说效果不佳。我建议将标签本身设置为可见false,而不仅仅是它们的父容器,因为从标签本身触发的重绘可能会通过。
您也可以尝试在show listener中触发动画,而不仅仅是callSerially
,这样可以让表单有足够的时间出现。