2012-02-22 74 views
2

在電子墨水屏幕上滾動屏幕和動畫是不好的事情。他們快速的屏幕刷新使屏幕瘋狂地閃爍(首先是負面的,然後是黑色的,然後是新的內容,多次重複滾動)。適應滾動/滑動到電子墨水屏幕

馴服電子墨水屏幕的一個簡單方法是將滾動更改爲分頁。另一種方法是仍然滾動 - 卻沒有表現出中間的屏幕更新:滾動前 屏幕 - >擡起手指:更新屏幕滾動後滾動前 屏幕 - >離開手指+超時:更新到實際屏幕

  • 任何想法如何實現?
  • 有沒有辦法教/覆蓋現有的滾動代碼?

THX

回答

0
@Override 
public boolean dispatchTouchEvent(MotionEvent event) 
{ 
    switch(event.getAction()) 
    { 
     case MotionEvent.ACTION_DOWN: 
     hit_scrollx = view.getScrollX(); 
     hit_scrolly = view.getScrollY(); 
     hit_touchx = (int) event.getX(); 
     hit_touchy = (int) event.getY(); 
     break; 
     case MotionEvent.ACTION_UP: 
     int x = (int) event.getX(); 
     int y = (int) event.getY(); 
     if (x<hit_touchx-5 || x>hit_touchx+5 || y<hit_touchy-5 || y>hit_touchy+5) 
      scrollAbsolute(hit_scrollx+hit_touchx-x, hit_scrolly+hit_touchy-y); 
     break; 
    } 
    return(true); 
} 

這假設你有自己的scrollAbsolute這確實剪裁爲您的應用和使用View.scrollTo。這是爲具有主滾動視圖的活動而設計的。它捕獲所有觸摸事件。 「5」是爲了防止在無意義的觸摸上進行不必要的刷新。