HoloCircularProgressBar 使用

本文介绍如何使用HoloCircularProgressBar组件创建一个圆形进度条,并通过动画实现目标进度的显示。包括关键属性配置及动画效果的实现。

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

圆形进度条

<com.pascalwelsch.holocircularprogressbar.HoloCircularProgressBar
                android:id="@+id/holoCircularProgressBar"
                android:layout_width="300dp"
                android:layout_height="300dp"
                app:marker_progress="1"
                app:marker_visible="false"
                app:thumb_visible="false"
                app:progress="0"
                />

 

其中: mark_progress 为目标进度

   thumb_visible 为走动的指示

progress 初始的进度位置

   progress_color颜色

调用动画

private void animate(final HoloCircularProgressBar progressBar, final Animator.AnimatorListener listener,
                         final float progress, final int duration) {

        mProgressBarAnimator = ObjectAnimator.ofFloat(progressBar, "progress", progress);
        mProgressBarAnimator.setDuration(duration);

        mProgressBarAnimator.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationCancel(final Animator animation) {
            }

            @Override
            public void onAnimationEnd(final Animator animation) {
                progressBar.setProgress(progress);
            }

            @Override
            public void onAnimationRepeat(final Animator animation) {
            }

            @Override
            public void onAnimationStart(final Animator animation) {
            }
        });
        if (listener != null) {
            mProgressBarAnimator.addListener(listener);
        }
        mProgressBarAnimator.reverse();
        mProgressBarAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                progressBar.setProgress((Float) animation.getAnimatedValue());
            }
        });
        progressBar.setMarkerProgress(progress);
        mProgressBarAnimator.start();
    }

 

转载于:https://www.cnblogs.com/qingducx/p/5233592.html

刻度样式进度条的载入控件, 除了刻度进度条外,其他任何部分都可自定义。项目地址:https://github.com/glomadrian/dashed-circular-progress 效果图:如何使用:<com.github.glomadrian.dashedcircularprogress.DashedCircularProgress         android:layout_width="300dp"         android:layout_height="300dp">         //这里你可以添加任意View,他将显示在控件的中心位置     </com.github.glomadrian.dashedcircularprogress.DashedCircularProgress>比如:<com.github.glomadrian.dashedcircularprogress.DashedCircularProgress         android:id="@ id/progress"                 android:layout_centerInParent="true"         android:layout_width="300dp"         android:layout_height="300dp"         custom:min="0"         custom:max="100"         custom:duration="3500"         custom:progress_icon="@drawable/android">         <TextView android:id="@ id/text"                 android:textSize="25sp"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                  android:text=""/>     </com.github.glomadrian.dashedcircularprogress.DashedCircularProgress>添加了一个用于显示进度的Textview。 你也可以添加ImageView等任何View。java代码:progress = (DashedCircularProgress)this.findViewById(R.id.progress); text = (TextView)this.findViewById(R.id.text); progress.setOnValueChangeListener( new DashedCircularProgress.OnValueChangeListener() {//监听进度值的变化,     @Override     public void onValueChange(float value) {         text.setText((int) value   "%");显示进度值     } }); progress.setValue(50);//设置当前的进度值为50。注意progress.setValue()设置的并不是进度的百分比。而要知道进度完成的百分比,你还需要设置progress.setMax(),progress.setMin() 即进度的最大值、最小值。属性说明:external_color  外圈圆环的颜色base_color    内圈(显示进度的)圆环颜色progress_color  内圈已完成部分的圆环颜色max   进度最大值min   进度最小值progress_icon  设置顶端的图标duration  进度改变时,需要多长时间的动画达到这个值
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值