private void init(Context context, AttributeSet attrs) {
        if (attrs != null) {
            TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.InfiniteBannerView);
            mDividerWidth = a.getDimensionPixelSize(R.styleable.InfiniteBannerView_bannerDividerWidth, mDividerWidth);
            mPager.initPosition(a.getInt(R.styleable.InfiniteBannerView_bannerInitialPage, 0));
            mIsManuallyScrollLocked = a.getBoolean(R.styleable.InfiniteBannerView_bannerManuallyScrollLock, false);
            mIsAutoScroll = a.getBoolean(R.styleable.InfiniteBannerView_bannerAutoScroll, false);
            mIsReverse = a.getBoolean(R.styleable.InfiniteBannerView_bannerScrollReverse, false);
            float foregroundWidthPercent = a.getFloat(R.styleable.InfiniteBannerView_bannerForegroundWidthPercent, mForegroundWidthPercent);
            if (foregroundWidthPercent < 1f){
                setForegroundWidthPercent(foregroundWidthPercent);
            }
            String s = a.getString(R.styleable.InfiniteBannerView_bannerLoopInterval);
            if (s != null) {
                try {
                    mLoopInterval = Long.parseLong(s);
                } catch (NumberFormatException e) {
                    Log.e("InfiniteBannerView", e.getMessage());
                }
            }
            a.recycle();
        }
        mScroller = new Scroller(context);
        ViewConfiguration config = ViewConfiguration.get(context);
        mTouchSlop = config.getScaledPagingTouchSlop();
        mMaxVelocity = config.getScaledMinimumFlingVelocity();
    }
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