- 引入依赖
implementation 'com.github.Justson:CoolIndicator:v1.0.0'
-
CoolIndicatorLayout布局
public class CoolIndicatorLayout extends BaseIndicatorView {
CoolIndicator mCoolIndicator = null;
public CoolIndicatorLayout(Context context) {
this(context, null);
}
public CoolIndicatorLayout(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, -1);
}
@SuppressLint("UseCompatLoadingForDrawables")
public CoolIndicatorLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mCoolIndicator = CoolIndicator.create((Activity) context);
mCoolIndicator.setProgressDrawable(context.getResources().getDrawable(com.coolindicator.sdk.R.drawable.default_drawable_indicator, context.getTheme()));
this.addView(mCoolIndicator, offerLayoutParams());
}
@Override
public LayoutParams offerLayoutParams() {
return new FrameLayout.LayoutParams(-1, AgentWebUtils.dp2px(getContext(), 3));
}
@Override
public void show() {
this.setVisibility(View.VISIBLE);
mCoolIndicator.start();
}
@Override
public void setProgress(int newProgress) {
}
@Override
public void hide() {
mCoolIndicator.complete();
}
将useDefaultIndicator()换成setCustomIndicator()方法
// .useDefaultIndicator()
.setCustomIndicator(CoolIndicatorLayout(this))
效果