android api 之Scroller

來源:互聯網
上載者:User

標籤:android   blog   http   io   ar   使用   for   strong   sp   

Scroller是封裝了滾動,實現View和ViewGroup的背景畫布的滾動。它有兩個構造方法:public Scroller (Context context)  傳遞一個上下文。
public Scroller (Context context, Interpolator interpolator)傳遞一個上下文,一個自訂的滾動方式。控制快慢程度的。


Scroller的主要方法有:public void startScroll (int startX, int startY, int dx, int dy, int duration)public void startScroll (int startX, int startY, int dx, int dy)開始滾動,傳遞開始的座標,和X Y軸的位移。第一個方法是重構的,多傳遞一個滾動時間的參數。
public final int getDuration ()擷取一共滾動的時間。如果沒有傳遞運動時間進去,則預設的是250ms
public final int getCurrX ()public final int getCurrY ()這兩個方法按照字面意思可以理解,擷取當前的座標的X Y。
public final int getStartX ()public final int getStartY ()擷取開始滾動時的X Y 座標

public final int getFinalX ()public final int getFinalY ()擷取最終的X Y 座標
public void fling (int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY)在fling ( 快滑,使用者按下觸控螢幕、快速移動後鬆開 ) 手勢基礎上開始滾動。滾動的距離取決於fling的初速度。

public final boolean isFinished ()返回scroller是否已完成滾動。

public int timePassed ()已經滾動了多長時間了。


public void extendDuration (int extend)

  延長滾動動畫時間。此函數允許當使用setFinalX(int) or setFinalY(int) 時,捲動動作持續更長時間並且捲動更長距離。

          參數

              extend 捲動事件延長的時間,以毫秒為單位

          參見

              setFinalX(int)

              setFinalY(int)


public final void forceFinished (boolean finished)

  強制終止的欄位到特定值。(譯者註:立即停止滾動?)

      參數

          finished    新的結束值

 

public void abortAnimation ()

  停止動畫。與forceFinished(boolean)相反,Scroller滾動到最終x與y位置時中止動畫。

  參見

        forceFinished(boolean)


  public boolean computeScrollOffset ()

  當想要知道新的位置時,調用此函數。如果返回true,表示動畫還沒有結束。位置改變以提供一個新的位置。




一部分參考:http://www.cnblogs.com/over140/archive/2010/12/16/1907528.html  






















來自為知筆記(Wiz)

android api 之Scroller

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.