From 0186b3aac7b03eaed706f13b7362e348fb4337a3 Mon Sep 17 00:00:00 2001 From: zhangpan Date: Wed, 6 Nov 2019 12:03:20 +0800 Subject: [PATCH] Fix a bug --- .../zhpan/circleviewpager/activity/PageStyleActivity.java | 2 +- .../src/main/java/com/zhpan/bannerview/BannerViewPager.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/activity/PageStyleActivity.java b/app/src/main/java/com/example/zhpan/circleviewpager/activity/PageStyleActivity.java index 3858cf7a..ea5209cf 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/activity/PageStyleActivity.java +++ b/app/src/main/java/com/example/zhpan/circleviewpager/activity/PageStyleActivity.java @@ -25,9 +25,9 @@ private void setupBanner() { mBannerViewPager .setPageMargin(DpUtils.dp2px(20)) .setRevealWidth(DpUtils.dp2px(20)) + .setPageStyle(PageStyle.MULTI_PAGE) .setHolderCreator(() -> new ImageResourceViewHolder(DpUtils.dp2px(5))) .setIndicatorColor(Color.parseColor("#935656"), Color.parseColor("#FF4C39")) - .setPageStyle(PageStyle.MULTI_PAGE) .setOnPageClickListener(position -> ToastUtils.show("position:" + position)) .create(mDrawableList); } diff --git a/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java b/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java index 79fe6d24..a7c250b6 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java @@ -304,7 +304,7 @@ private void setupViewPager() { } } - private void initPageStyle(){ + private void initPageStyle() { switch (mPageStyle) { case PageStyle.MULTI_PAGE: setMultiPageStyle(); @@ -717,6 +717,8 @@ public BannerViewPager setPageStyle(@APageStyle int pageStyle) { } private void setMultiPageStyle() { + mPageMargin=mPageMargin==0?DpUtils.dp2px(20):mPageMargin; + mRevealWidth=mRevealWidth==0?DpUtils.dp2px(20):mRevealWidth; setClipChildren(false); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mViewPager.getLayoutParams(); params.leftMargin = mPageMargin + mRevealWidth;