當前位置: 首頁>>代碼示例>>Java>>正文


Java Scroller.forceFinished方法代碼示例

本文整理匯總了Java中android.widget.Scroller.forceFinished方法的典型用法代碼示例。如果您正苦於以下問題:Java Scroller.forceFinished方法的具體用法?Java Scroller.forceFinished怎麽用?Java Scroller.forceFinished使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Scroller的用法示例。


在下文中一共展示了Scroller.forceFinished方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: moveToFinalScrollerPosition

import android.widget.Scroller; //導入方法依賴的package包/類
/**
 * Move to the final position of a scroller. Ensures to force finish the scroller
 * and if it is not at its final position a scroll of the selector wheel is
 * performed to fast forward to the final position.
 *
 * @param scroller The scroller to whose final position to get.
 * @return True of the a move was performed, i.e. the scroller was not in final position.
 */
private boolean moveToFinalScrollerPosition(Scroller scroller) {
    scroller.forceFinished(true);
    int amountToScroll = scroller.getFinalY() - scroller.getCurrY();
    int futureScrollOffset = (mCurrentScrollOffset + amountToScroll) % mSelectorElementHeight;
    int overshootAdjustment = mInitialScrollOffset - futureScrollOffset;
    if (overshootAdjustment != 0) {
        if (Math.abs(overshootAdjustment) > mSelectorElementHeight / 2) {
            if (overshootAdjustment > 0) {
                overshootAdjustment -= mSelectorElementHeight;
            } else {
                overshootAdjustment += mSelectorElementHeight;
            }
        }
        amountToScroll += overshootAdjustment;
        scrollBy(0, amountToScroll);
        return true;
    }
    return false;
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:28,代碼來源:NumberPicker.java


注:本文中的android.widget.Scroller.forceFinished方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。