From 50aacfed3ceb60997c2c9a4cc0f9e6fe6b5ed718 Mon Sep 17 00:00:00 2001 From: 陈奇 <1650699704@qq.com> Date: Mon, 26 Nov 2018 15:17:11 +0800 Subject: [PATCH] [*]修改主页指针跳转动画 --- app/src/main/java/com/moral/yunfushao/ui/PanelView.java | 40 +++++++++++++++++----------------------- 1 files changed, 17 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/moral/yunfushao/ui/PanelView.java b/app/src/main/java/com/moral/yunfushao/ui/PanelView.java index 5929488..20de007 100644 --- a/app/src/main/java/com/moral/yunfushao/ui/PanelView.java +++ b/app/src/main/java/com/moral/yunfushao/ui/PanelView.java @@ -14,6 +14,7 @@ import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; +import android.view.animation.Animation; import com.moral.yunfushao.R; @@ -76,7 +77,7 @@ private Bitmap mBitmap; private float percent = 0;//��������������� - private float percent2 = (float) 0.27;//��������������� + private float percent2 = 0;//��������������� private String statusStr = "���������"; @@ -88,14 +89,8 @@ } public void setPercent(float percent) { - this.percent = percent; -// this.percent2 = percent; - postInvalidate(); -// if (anim.isStarted() || anim.isRunning()) { -// anim.end(); -// anim.cancel(); -// } -// anim.start(); + this.percent2 = percent; + startAnimation(); } public PanelView(Context context) { @@ -160,7 +155,6 @@ mBitPaint.setFilterBitmap(true); mBitPaint.setDither(true); mBitmap = ((BitmapDrawable) mContext.getResources().getDrawable(R.mipmap.zhizhen)).getBitmap(); -// startAnimation(); } @Override @@ -184,19 +178,19 @@ setMeasuredDimension(mmWidth, mmHeight); } -// private void startAnimation() { -// anim = ValueAnimator.ofObject(new CustomPointEvaluator(),(float)0, percent2); -// anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { -// @Override -// public void onAnimationUpdate(ValueAnimator animation) { -// percent = (float) animation.getAnimatedValue(); -// System.out.println("chenqi rotato " + percent + " all -> " + percent2 * 300); -//// invalidate(); -// } -// }); -// anim.setDuration(3000L); -// anim.setRepeatCount(Animation.INFINITE); -// } + private void startAnimation() { + anim = ValueAnimator.ofFloat((float) percent, percent2); + anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + percent = (float) animation.getAnimatedValue(); + postInvalidate(); + } + }); + anim.setDuration(3000L); + anim.setRepeatCount(Animation.INFINITE); + anim.start(); + } // // private class CustomPointEvaluator implements TypeEvaluator<Float> { // @Override -- Gitblit v1.8.0