android ValueAnimator属性动画 onAnimationUpdate回调异常?
使用属性动画遇到异常以下是我的代码,点击一个View然后这个View执行一个高度变化的动画。但是动画没有按照预期出现。加上LOG以后发现动画的回调只调了两次,而且返回的值是最大值。各路大神求解!
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.product_item_top_rl:
startAnimation(v);
break;
}
}
private void startAnimation(final View v) {
int height = v.getHeight();
ValueAnimator va = ValueAnimator.ofInt(0, height);
va.setDuration(1000);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Log.d(TAG, "animation : " + animation.getAnimatedValue());
v.getLayoutParams().height = (Integer) animation.getAnimatedValue();
v.requestLayout();
}
});
va.start();
}
D/ChooseProductFragment: animation : 150
D/ChooseProductFragment: animation : 150
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题解决了。是因为我昨天为了用espresso做UI自动化测试,在设置里面关闭了“窗口动画缩放”,“过度动画缩放”,“动画程序时长调整”这三个动画。重新开放这些动画就正常了。
你没有指定动画的循环次数和方式,应该加上