我正在开发电子书应用程序,需要从左到右和从右到左切换屏幕。我尝试了很多我发现的样本,但我没有成功。当用户从左到右和从右到左点击屏幕时,如何频繁更改屏幕。页面转换的基本思路是什么?我通过开发者支持论坛线程"page-flip effect"寻找解决方案,但我看不到它。当用户点击位图时执行屏幕切换
以下代码不合逻辑。我在哪个位置必须实现翻转屏幕中翻页的效果以及如何实现?
public class TransitionScreen extends FullScreen implements Runnable{
private int angle = 0;
Bitmap fromBmp,toBmp;
public TransitionScreen(){
}
public TransitionScreen(AnimatableScreen from,AnimatableScreen to) {
fromBmp = new Bitmap(Display.getWidth(), Display.getHeight());
toBmp = new Bitmap(Display.getWidth(), Display.getHeight());
Graphics fromGraphics = Graphics.create(fromBmp);
Graphics toGraphics = Graphics.create(toBmp);
Object eventLock = getApplication().getEventLock();
synchronized(eventLock) {
from.drawAnimationBitmap(fromGraphics);
to.drawAnimationBitmap(toGraphics);
// Interpolate myOffset to target
// Set animating = false if myOffset = target
invalidate();
}
try {
synchronized (Application.getEventLock()) {
Ui.getUiEngine().suspendPainting(true);
}
} catch (final Exception ex) {
}
}
protected void paint(Graphics g){
//control x,y positions of the bitmaps in the timer task and the paint will just paint where they go
g.drawBitmap(0,0, 360,
480, toBmp, 0, 0);
g.drawBitmap(0, 0, 360,
480, fromBmp, 0, 0);
// invalidate();
}
protected boolean touchEvent(TouchEvent event) {
if (!this.isFocus())
return true;
if (event.getEvent() == TouchEvent.CLICK) {
// invalidate();
}
return super.touchEvent(event);
}
}
感谢您的回复。我需要所有Touch版本的页面翻页效果,这是来自4.7 OS。如何处理页面的翻页效果。 – Koushik 2011-01-25 16:19:54