diff --git a/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java b/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java index eb00138..d32a6bc 100755 --- a/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java +++ b/library/src/main/java/me/itangqi/waveloadingview/WaveLoadingView.java @@ -60,6 +60,7 @@ public class WaveLoadingView extends View { private static final float DEFAULT_TITLE_TOP_SIZE = 18.0f; private static final float DEFAULT_TITLE_CENTER_SIZE = 22.0f; private static final float DEFAULT_TITLE_BOTTOM_SIZE = 18.0f; + private int progressDuration = 1000; public enum ShapeType { TRIANGLE, @@ -558,7 +559,7 @@ public float getAmplitudeRatio() { public void setProgressValue(int progress) { mProgressValue = progress; ObjectAnimator waterLevelAnim = ObjectAnimator.ofFloat(this, "waterLevelRatio", mWaterLevelRatio, ((float) mProgressValue / 100)); - waterLevelAnim.setDuration(1000); + waterLevelAnim.setDuration(progressDuration); waterLevelAnim.setInterpolator(new DecelerateInterpolator()); AnimatorSet animatorSetProgress = new AnimatorSet(); animatorSetProgress.play(waterLevelAnim); @@ -836,4 +837,12 @@ else if (direction == 3) { return path; } + + /** + * set duration of progress change animation, 1000ms by default + * @param progressDuration duration of progress change animation + */ + public void setProgressDuration(int progressDuration) { + this.progressDuration = progressDuration; + } } diff --git a/sample/src/main/java/me/itangqi/waveloadingview/MainActivity.java b/sample/src/main/java/me/itangqi/waveloadingview/MainActivity.java index 9cb18dd..294b8b8 100644 --- a/sample/src/main/java/me/itangqi/waveloadingview/MainActivity.java +++ b/sample/src/main/java/me/itangqi/waveloadingview/MainActivity.java @@ -27,6 +27,7 @@ protected void onCreate(Bundle savedInstanceState) { mWaveLoadingView = (WaveLoadingView) findViewById(R.id.waveLoadingView); // Sets the length of the animation, default is 1000. mWaveLoadingView.setAnimDuration(3000); + mWaveLoadingView.setProgressDuration(3000); // Shape Type findViewById(R.id.tv_shape).setOnClickListener(new View.OnClickListener() {