HoloCircularProgressBar 使用

圆形进度条

<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();
    }

 

posted @ 2016-03-02 09:09  清渡茶叶  阅读(683)  评论(0编辑  收藏  举报