android仿薄荷卷尺系列文章

3.2改进仿薄荷卷次控件之限制HorizontalScroll完

2017-11-05  本文已影响14人  真胖大海

本篇文章属于android仿薄荷卷尺系列文章

关键代码
Scroller.computeScrollOffset()调用一次后,再调用一次Scroller.computeScrollOffset(),如果返回false,则表明滚动快要完成了,则直接调用ajutScroollX调整偏移量

   @Override
    public void computeScroll() {
        super.computeScroll();
        if (mFlingScroller.computeScrollOffset()) {
            int currX = mFlingScroller.getCurrX();
            Log.i(TAG, "computeScroll: " + currX);
            scrollTo(currX, mFlingScroller.getCurrY());

            if (!mFlingScroller.computeScrollOffset()) {
                ajustScrollX();
            }
            invalidate();
            Log.i(TAG, "computeScroll: 重绘");
        }


    }
上一篇 下一篇

猜你喜欢

热点阅读