@Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);

        if (getItemCount() > 0) {
            int periodLength = getPeriodLength(getWidth());
            int page = l / periodLength;
            int positionOffsetPixels = l % periodLength;
            if (l < 0){
                page -= 1;
                positionOffsetPixels += periodLength;
            }
            float positionOffset = (float) positionOffsetPixels / (float) periodLength;
            onPageScrolledInternal(page, positionOffset, positionOffsetPixels);
        }
    }
A banner view that can automatically or manually scroll in a loop
Created by Marksss on 2019/8/12.
imitate/src/main/java/com/engineer/imitate/ui/widget/opensource/InfiniteBannerView.java