3.2改进仿薄荷卷次控件之限制HorizontalScroll完成滑动后的距离调整

本篇文章属于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: 重绘");
        }


    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容