动画图像(即同时生长和淡入)

时间:2016-03-23 06:59:24

标签: animation fadein codenameone

我正在创建一个启动画面。到目前为止,我可以实现成长效果或淡入效果。尝试同时获取两个动画时,它无法正常工作。

//zooms or grows the image
findImageViewerSplash(f).growShrink(1000);
//for fade in effect
findContainerImageViewer(f).animateLayoutFadeAndWait(2000, 0);

使用图像查看器来获得增长效果。这里的图像查看器组件位于ContainerImageViewer中。如果我注释掉其中一行,它可以工作,但实现两者都行不通。 三江源

setUIID为scaleImageLabel时的异常。

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.codename1.impl.javase.Executor$1$1.run(Executor.java:100)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1149)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:966)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Caused by: java.lang.NullPointerException
    at com.codename1.components.ScaleImageLabel.calcPreferredSize(ScaleImageLabel.java:83)
    at com.codename1.ui.Component.preferredSizeImpl(Component.java:1930)
    at com.codename1.ui.Component.preferredSize(Component.java:1965)
    at com.codename1.ui.Component.setPreferredSize(Component.java:735)
    at userclasses.StateMachine.beforeSplashScreen(StateMachine.java:178)
    at generated.StateMachineBase.beforeShow(StateMachineBase.java:883)
    at com.codename1.ui.util.UIBuilder.showForm(UIBuilder.java:2514)
    at com.codename1.ui.util.UIBuilder.showForm(UIBuilder.java:2561)
    at generated.StateMachineBase.startApp(StateMachineBase.java:60)
    at generated.StateMachineBase.<init>(StateMachineBase.java:31)
    at generated.StateMachineBase.<init>(StateMachineBase.java:106)
    at userclasses.StateMachine.<init>(StateMachine.java:78)
    at com.ruslanVodka_CapitalEye.myapp.RuslanApp.start(RuslanApp.java:23)
    ... 9 more

1 个答案:

答案 0 :(得分:0)

这些效果彼此独有,您可以并行运行它们。

您实际上不需要growShrink来电,因为animateLayout*来电会根据您的首选尺寸定义增长/缩小。

以下是使用动画布局生成“增长”效果的示例:

Form hi = new Form("Grow", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER));
int w = Display.getInstance().getDisplayWidth();
ScaleImageLabel dukeLabel = new ScaleImageLabel(duke);
dukeLabel.setPreferredSize(new Dimension(w / 3, w / 3));
hi.add(BorderLayout.CENTER, dukeLabel);
hi.addShowListener((e) -> {
    dukeLabel.setPreferredSize(new Dimension(w, w));
    dukeLabel.getParent().animateLayout(5000);
});

hi.show();