有没有人知道如何使用黑莓JDE API创建类似于黑莓应用程序世界中的特色项目屏幕的屏幕幻灯片动画?我知道在黑莓5.0中,有一些过渡api来执行它.但我希望在4.6版操作系统上做到这一点.它使用黑莓粗体滚动球具有很好的滚动效果.
谢谢.
最佳答案
作为截图/位图方法的替代方案……
原文链接:https://www.f2er.com/java/437612.html在屏幕的绘制方法中,您可以使用Graphics.pushContext(..)来推送剪切区域和绘制偏移.为了获得最佳结果,您需要在runnable中进行转换,并在事件锁定上进行同步.这将确保您的屏幕可以在转换过程中被解除.
粗略的例子:
class TransitionScreen extends Screen {
private int transitionOffset;
private boolean isTransitionHorizontal;
private ScreenTransition currentTransition;
public TransitionScreen(boolean isTransitionHorizontal) {
this.isTransitionHorizontal = isTransitionHorizontal;
transitionOffset = getTransitionMaximum(); // So the screen starts offset
}
protected void paint(Graphics graphics) {
// use transitionOffset as x or y depending on isTransitionHorizontal
graphics.pushContext(...);
}
protected void onExposed() {
transitionToOffset(0);
}
protected void onObscured() {
int target = getTransitionMaximum();
transitionToOffset(target);
}
private int getTransitionMaximum() {
return isTransitionHorizontal ? Display.getWidth() : Display.getHeight();
}
private void transitionToOffset(int target) {
if (currentTransition != null) {
currentTransition.stop();
}
currentTransition = new ScreenTransition(target);
getApplication().invokeLater(currentTransition);
}
}
class ScreenTransition implements Runnable {
private boolean animating;
private int target;
public ScreenTransitionUpdater(int target) {
this.target = target;
}
public void stop() {
animating = false;
}
public void run() {
while(animating) {
Object eventLock = getApplication().getEventLock();
synchronized(eventLock) {
// Interpolate myOffset to target
// Set animating = false if myOffset = target
invalidate();
}
}
}
}
无需将动画标记为易变,因为在此平台上忽略它.