继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

自定义TypeEvaluator

弑天下
关注TA
已关注
手记 141
粉丝 12
获赞 51

根据传入值的变化,产生动画效果

ValueAnimator myAnimator = ValueAnimator.ofObject(new MyEvaluator(), "hello", "world");

myAnimator.addUpdateListener(new AnimatorUpdateListener() {

@Override

public void onAnimationUpdate(ValueAnimator animation) {

String animatedValue = (String) animation.getAnimatedValue();

textView.setText(animatedValue);

}

});

myAnimator.setDuration(DURATION);

myAnimator.start();

private class MyEvaluator implements TypeEvaluator<String> {

@Override

public String evaluate(float fraction, String startValue,

String endValue) {

String result = startValue+fraction;

if (fraction == 0) {

result = "start";

} else if (fraction == 1) {

result += endValue;

}

return result;

}

原文链接:http://www.apkbus.com/blog-880881-63308.html

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP