属性动画不按逻辑执行,比如直接执行结束
public void start() {
anim = null;
if (anim == null) {
anim = ObjectAnimator.ofInt(ia, "start", 0, 360);
}
anim.setInterpolator(new LinearInterpolator());
anim.setDuration(MAX_DURATION); // 1 minute
anim.addUpdateListener(this);
// anim.addListener(this);
long duration = anim.getDuration();
System.out.println(duration);
anim.start();
}
该代码片段执行逻辑是0 到 360递增,但是在某些手机上直接执行到360,显然这是不能原谅的.
---
网上一顿找,
http://blog.youkuaiyun.com/luojiusan520/article/details/51207597
发现按这个设置,属性动画照样不好使.
突然间想到以前遇到的问题,
我想要虚线,可以用shape表示,结果不显示
一顿找
添加如下属性即可 android:layerType="software"
我想问题就应该是它了,结果我试了一下,问题解决,动画按要求执行
修改后的代码片段:
public void start() {
anim = null;
if (anim == null) {
anim = ObjectAnimator.ofInt(ia, "start", 0, 360);
}
anim.setInterpolator(new LinearInterpolator());
anim.setDuration(MAX_DURATION); // 1 minute
anim.addUpdateListener(this);
// anim.addListener(this);
long duration = anim.getDuration();
setLayerType(LAYER_TYPE_SOFTWARE, paint); //搞定了哈哈哈哈
anim.start();
}
....
又遇到问题,设置以上代码在联想手机上也不行,我靠,无语了.真解决不了~