Skip to content

Commit edc8e4c

Browse files
committed
add attr pictureSpacing
1 parent ba66964 commit edc8e4c

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
app:bottomType="belowPic" // 底部整体小点在轮播控件里面的位置,是底部覆盖在轮播图上,还是在轮播图下方
3131
3232
app:dotSize="10dp" //小点之间的间距
33+
34+
app:pictureSpacing="10" // 两边突出时 两张图片之间的间隔距离 可以不用设置 默认值是10
3335

3436

3537

@@ -70,6 +72,7 @@
7072
app:widthProportion="8"
7173
app:heightProportion="3"
7274
app:bulge="true"
75+
app:pictureSpacing="10"
7376
app:bulgeDistance="30"
7477
app:bottomType="belowPic"
7578
app:dotSize="10dp" />

app/src/main/res/layout/activity_banner.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
app:widthProportion="8"
3737
app:heightProportion="3"
3838
app:bulge="true"
39-
app:bulgeDistance="30"
39+
app:pictureSpacing="10"
40+
app:bulgeDistance="40"
4041
app:bottomType="belowPic"
4142
app:dotSize="10dp" />
4243

lbannerview/src/main/java/json/xxl/com/lbannerview/BannerView.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class BannerView extends RelativeLayout {
4242
private int mBulgeDistance = 25;//两边凸出距离
4343
private int mBottomType = 0;//小点 文字描述位置 默认底部类型是小点覆盖在图片上) 0位覆盖在图片上 1是在底部图片下方
4444
private boolean mScollFlag = false;//滚动标记 标记是否设置过滚动
45+
private int mPictureSpacing = 10; // 两张图片之间的间距
4546

4647
public BannerView(Context context) {
4748
this(context, null);
@@ -80,7 +81,7 @@ private void initView() {
8081
LayoutParams layoutParams = (LayoutParams) mBannerViewPager.getLayoutParams();
8182
layoutParams.setMargins(dip2px(mBulgeDistance), 0, dip2px(mBulgeDistance), 0);
8283
mBannerViewPager.setLayoutParams(layoutParams);
83-
mBannerViewPager.setPageMargin(10);//ViewPager页面之间的距离
84+
mBannerViewPager.setPageMargin(mPictureSpacing);//ViewPager页面之间的距离
8485
}
8586

8687
//手先判断是否是shape等drawable文件作为底部容器的背景,有的话就优先使用,没有的话判断是否传入了颜色值
@@ -126,6 +127,7 @@ private void initAttribute(AttributeSet attrs) {
126127
//获取自定义属性,宽高比
127128
mWidthProportion = (int) typedArray.getFloat(R.styleable.BannerView_widthProportion, mWidthProportion);
128129
mHeightProportion = (int) typedArray.getFloat(R.styleable.BannerView_heightProportion, mHeightProportion);
130+
mPictureSpacing = (int) typedArray.getFloat(R.styleable.BannerView_pictureSpacing, mPictureSpacing);
129131
mBulge = typedArray.getBoolean(R.styleable.BannerView_bulge, mBulge);
130132
mBulgeDistance = typedArray.getInteger(R.styleable.BannerView_bulgeDistance, mBulgeDistance);
131133
mBottomType = typedArray.getInt(R.styleable.BannerView_bottomType, mBottomType);

lbannerview/src/main/res/values/attrs.xml

+2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@
3535
<!--底部在图片下方-->
3636
<enum name="belowPic" value="1"/>
3737
</attr>
38+
<!--两张图片之间的间距-->
39+
<attr name="pictureSpacing" format="float"/>
3840
</declare-styleable>
3941
</resources>

0 commit comments

Comments
 (0)