您的位置:首页 > 其它

属性动画在某些机器不按逻辑执行

2016-12-19 11:27 225 查看
属性动画不按逻辑执行,比如直接执行结束

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.csdn.net/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();

}

....

又遇到问题,设置以上代码在联想手机上也不行,我靠,无语了.真解决不了~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: