我正在開發電子書應用程序,需要從左到右和從右到左切換屏幕。我嘗試了很多我發現的樣本,但我沒有成功。當用戶從左到右和從右到左點擊屏幕時,如何頻繁更改屏幕。頁面轉換的基本思路是什麼?我通過開發者支持論壇線程"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