下面列出了android.view.animation.AccelerateInterpolator#getInterpolation() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void animateUp(long delta)
{
boolean finished = false;
int minHeight = (int) (fromHeightPart * bar.getMaxHeight());
int toHeight = (int) (bar.getMaxHeight() * toHeightPart);
float timePart = (float) delta / BAR_ANIMATION_UP_DURATION;
AccelerateInterpolator interpolator = new AccelerateInterpolator();
int height = minHeight + (int) (interpolator.getInterpolation(timePart) * (toHeight - minHeight));
if (height < bar.getHeight()) {
return;
}
if (height >= toHeight) {
height = toHeight;
finished = true;
}
bar.setHeight(height);
bar.update();
if (finished) {
isUpAnimation = false;
startTimestamp = System.currentTimeMillis();
}
}
private void animateUp(long delta) {
boolean finished = false;
int minHeight = (int) (fromHeightPart * bar.getMaxHeight());
int toHeight = (int) (bar.getMaxHeight() * toHeightPart);
float timePart = (float) delta / BAR_ANIMATION_UP_DURATION;
AccelerateInterpolator interpolator = new AccelerateInterpolator();
int height = minHeight + (int) (interpolator.getInterpolation(timePart) * (toHeight - minHeight));
if (height < bar.getHeight()) {
return;
}
if (height >= toHeight) {
height = toHeight;
finished = true;
}
bar.setHeight(height);
bar.update();
if (finished) {
isUpAnimation = false;
startTimestamp = System.currentTimeMillis();
}
}
private void animateUp(long delta) {
boolean finished = false;
int minHeight = (int) (fromHeightPart * bar.getMaxHeight());
int toHeight = (int) (bar.getMaxHeight() * toHeightPart);
float timePart = (float) delta / BAR_ANIMATION_UP_DURATION;
AccelerateInterpolator interpolator = new AccelerateInterpolator();
int height = minHeight + (int) (interpolator.getInterpolation(timePart) * (toHeight - minHeight));
if (height < bar.getHeight()) {
return;
}
if (height >= toHeight) {
height = toHeight;
finished = true;
}
bar.setHeight(height);
bar.update();
if (finished) {
isUpAnimation = false;
startTimestamp = System.currentTimeMillis();
}
}