很酷的Android下載進度條:DownloadProgressBar

jopen 9年前發布 | 24K 次閱讀 Android開發 移動開發 DownloadProgressBar

一個帶有很酷動畫的Android進度條,設計源于https://dribbble.com/shots/2012292-Download-Animation


Download Progress Bar Animation

Download Progress Bar Animation


Attributes

</tr> </tbody>

</tr>

</tr>

</tr>

</tr>

</tr>

</tr>

</tr>

</tr>

</tr>

</tr> </tbody> </table>

下載

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.baiduhome.net/lib/view/home/1435633863200

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
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)
  • sesese色