Search in sources :

Example 1 with CompositePageTransformer

use of androidx.viewpager2.widget.CompositePageTransformer in project banner by youth5201314.

the class Banner method init.

private void init(Context context) {
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop() / 2;
    mCompositePageTransformer = new CompositePageTransformer();
    mPageChangeCallback = new BannerOnPageChangeCallback();
    mLoopTask = new AutoLoopTask(this);
    mViewPager2 = new ViewPager2(context);
    mViewPager2.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mViewPager2.setOffscreenPageLimit(2);
    mViewPager2.registerOnPageChangeCallback(mPageChangeCallback);
    mViewPager2.setPageTransformer(mCompositePageTransformer);
    ScrollSpeedManger.reflectLayoutManager(this);
    addView(mViewPager2);
    mRoundPaint = new Paint();
    mRoundPaint.setColor(Color.WHITE);
    mRoundPaint.setAntiAlias(true);
    mRoundPaint.setStyle(Paint.Style.FILL);
    mRoundPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
    mImagePaint = new Paint();
    mImagePaint.setXfermode(null);
}
Also used : ViewPager2(androidx.viewpager2.widget.ViewPager2) PorterDuffXfermode(android.graphics.PorterDuffXfermode) CompositePageTransformer(androidx.viewpager2.widget.CompositePageTransformer) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)1 PorterDuffXfermode (android.graphics.PorterDuffXfermode)1 CompositePageTransformer (androidx.viewpager2.widget.CompositePageTransformer)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1