AgentWeb使用CoolIndicator进度条

本文介绍了如何在Android应用中利用AgentWeb和CoolIndicator库,通过引入依赖、配置CoolIndicatorLayout以及替换默认指示器方法,实现自定义的Webview加载进度条效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 引入依赖
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))

效果

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值