[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

圆形指示器时添加指示器距banner底部间距 #114

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
|indicator_margin| dimension|指示器之间的间距
|indicator_drawable_selected| reference|指示器选中效果
|indicator_drawable_unselected| reference|指示器未选中效果
|circle_indicator_margin_bottom| dimension|CIRCLE_INDICATOR时有效,指示器与banner底部间距
|image_scale_type| enum |和imageview的ScaleType作用一样


Expand Down
19 changes: 19 additions & 0 deletions banner/src/main/java/com/youth/banner/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Banner extends FrameLayout implements OnPageChangeListener {
private int mIndicatorMargin = BannerConfig.PADDING_SIZE;
private int mIndicatorWidth;
private int mIndicatorHeight;
private int mCircleIndicatorMarginBottom;
private int indicatorSize;
private int bannerStyle = BannerConfig.CIRCLE_INDICATOR;
private int delayTime = BannerConfig.TIME;
Expand Down Expand Up @@ -97,6 +98,7 @@ private void handleTypedArray(Context context, AttributeSet attrs) {
mIndicatorWidth = typedArray.getDimensionPixelSize(R.styleable.Banner_indicator_width, indicatorSize);
mIndicatorHeight = typedArray.getDimensionPixelSize(R.styleable.Banner_indicator_height, indicatorSize);
mIndicatorMargin = typedArray.getDimensionPixelSize(R.styleable.Banner_indicator_margin, BannerConfig.PADDING_SIZE);
mCircleIndicatorMarginBottom = typedArray.getDimensionPixelSize(R.styleable.Banner_circle_indicator_margin_bottom, BannerConfig.CIRCLE_INDICATOR_MARGIN_BOTTOM);
mIndicatorSelectedResId = typedArray.getResourceId(R.styleable.Banner_indicator_drawable_selected, R.drawable.gray_radius);
mIndicatorUnselectedResId = typedArray.getResourceId(R.styleable.Banner_indicator_drawable_unselected, R.drawable.white_radius);
scaleType = typedArray.getInt(R.styleable.Banner_image_scale_type, scaleType);
Expand Down Expand Up @@ -166,6 +168,18 @@ public Banner setIndicatorGravity(int type) {
return this;
}

public void setCircleIndicatorMarginBottom(int marginBottom){
mCircleIndicatorMarginBottom = marginBottom;
if (bannerStyle == BannerConfig.CIRCLE_INDICATOR && mCircleIndicatorMarginBottom > 0) {
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) indicator.getLayoutParams();
params2.bottomMargin = mCircleIndicatorMarginBottom;
}
}

public int getCircleIndicatorMarginBottom(){
return mCircleIndicatorMarginBottom;
}

public Banner setBannerAnimation(Class<? extends PageTransformer> transformer) {
try {
setPageTransformer(true, transformer.newInstance());
Expand Down Expand Up @@ -409,6 +423,11 @@ private void createIndicator() {
indicator.addView(imageView, params);
else if (bannerStyle == BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
indicatorInside.addView(imageView, params);

if (bannerStyle == BannerConfig.CIRCLE_INDICATOR && mCircleIndicatorMarginBottom > 0) {
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) indicator.getLayoutParams();
params2.bottomMargin = mCircleIndicatorMarginBottom;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions banner/src/main/java/com/youth/banner/BannerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class BannerConfig {
* banner
*/
public static final int PADDING_SIZE=5;
public static final int CIRCLE_INDICATOR_MARGIN_BOTTOM=0;
public static final int TIME=2000;
public static final int DURATION=800;
public static final boolean IS_AUTO_PLAY=true;
Expand Down
1 change: 1 addition & 0 deletions banner/src/main/res/values/attr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<attr name="indicator_width" format="dimension" />
<attr name="indicator_height" format="dimension" />
<attr name="indicator_margin" format="dimension" />
<attr name="circle_indicator_margin_bottom" format="dimension" />
<attr name="indicator_drawable_selected" format="reference" />
<attr name="indicator_drawable_unselected" format="reference" />
<attr name="image_scale_type" format="enum">
Expand Down