| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

很酷的Android下载进度条:DownloadProgressBar

一个带有很酷动画的Android进度条,设计源于https://dribbble.com/shots/2012292-Download-Animation


Download Progress Bar Animation

Download Progress Bar Animation


Attributes

Attribute Type Usage
app:circleRadius dimension The dimension of the circle radius
app:strokeWidth dimension The dimension of the circle stroke width
app:lineWidth dimension Color used for the progress completed
app:progressDuration integer Duration of progress. Default value is set to 1000 ms
app:resultDuration integer Duration of result, either success and error. Default set to 4000 ms
app:overshootValue dimension Value of overshoot interpolator (used for popping up the circle)
app:drawingColor color Color used for drawing inside drawables (white on gif)
app:progressColor color Color used for drawing the progress (white on gif)
app:circleBackgroundColor color Color used for drawing background circle (light blue on gif)
app:progressBackgroundColor color Color used for drawing progress background (light blue on gif)

下载

repositories {      maven {          url "https://jitpack.io"      }  }    dependencies {      compile 'com.github.panwrona:DownloadProgressBar:1.0'  }

用法

首先需要区别的是两种结果:成功和失败。要播放成功动画,调用下面的一行代码:

DownloadProgressBar downloadProgressBar = (DownloadProgressBar)findViewById(R.id.download_progress_view);  downloadProgressBar.playToSuccess();

如果想播放错误动画,调用:

DownloadProgressBar downloadProgressBar = (DownloadProgressBar)findViewById(R.id.download_progress_view);  downloadProgressBar.playToError();

同时我还添加了常用事件的listener:whole animation start, whole animation end, progress update, animation success, animation error。要实现他们,如下:

downloadProgressBar.setOnProgressUpdateListener(new DownloadProgressBar.OnProgressUpdateListener() {              @Override              public void onProgressUpdate(float currentPlayTime) {                  // Here we are setting % value on our text view.                  successTextView.setText(Math.round(currentPlayTime / 3.6) + " %");              }                @Override              public void onAnimationStarted() {                  // Here we are disabling our view because of possible interactions while animating.                  downloadProgressBar.setEnabled(false);              }                @Override              public void onAnimationEnded() {                  successTextView.setText("Click to download");                  downloadProgressBar.setEnabled(true);              }                @Override              public void onAnimationSuccess() {                  successTextView.setText("Downloaded!");              }                @Override              public void onAnimationError() {                }          });

项目主页:http://www.open-open.com/lib/view/home/1435633863200

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1435633863200.html
Android开发 移动开发 DownloadProgressBar