我正在使用OUSHENG x8 mini pro,API 19(4.4.2)测试我的应用程序。
特别是我面临的问题是使用几个ValueAnimator对象动画的ProgressBar的行为:
private AnimatorSet animatorSet;
private ValueAnimator R2LAnimation;
private ValueAnimator L2RAnimation;
public ValueAnimator getL2RAnimation(final ProgressBar progressBar) {
ValueAnimator valueAnimator = ValueAnimator.ofInt(0, progressBar.getMax());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (Integer) animation.getAnimatedValue();
LogUtils.traceD(LOG_TAG, "Animation Progress Value: " + value);
progressBar.setProgress(value);
}
});
return valueAnimator;
}
public ValueAnimator getR2LAnimation(final ProgressBar progressBar) {
ValueAnimator valueAnimator = ValueAnimator.ofInt(progressBar.getMax(), 0);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (Integer) animation.getAnimatedValue();
LogUtils.traceD(LOG_TAG, "Animation Progress Value: " + value);
progressBar.setProgress(value);
}
});
return valueAnimator;
}
这是我的日志输出:
09-17 17:27:00.408 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.408 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.409 24923-25478/<MY APPLICATON ID> D/NativeCrypto: ssl=0x7ca17488 sslRead buf=0x42b3a8a0 len=8192,timeo=15000
09-17 17:27:00.411 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.413 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.414 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.422 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.422 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.425 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.426 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.426 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.431 24923-26483/<MY APPLICATON ID> D/FA: Connected to remote service
09-17 17:27:00.435 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.435 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.438 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.440 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.440 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.446 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.447 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.453 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.454 24923-26483/<MY APPLICATON ID> D/SQLiteDatabase: beginTransaction()
09-17 17:27:00.456 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.457 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.464 24923-26483/<MY APPLICATON ID> D/SQLiteDatabase: endTransaction()
09-17 17:27:00.464 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.466 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.470 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.472 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.473 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.482 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.483 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.491 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.494 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.496 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.502 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.502 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.510 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.514 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.525 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.573 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.573 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.616 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
09-17 17:27:00.621 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: drawRect multiDraw View @42138848 paint 0x82af3e08 id 5 style 0 AA 0 color 0x1f000000
09-17 17:27:00.622 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: finish <0x80659aa0>
09-17 17:27:00.635 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 17:27:00.635 24923-24923/<MY APPLICATON ID> D/<MY ACTIVITY>: Animation Progress Value: 1000
09-17 17:27:00.637 24923-24923/<MY APPLICATON ID> D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1280.00) opaque 1 <0x80659aa0>
...
(这种情况一直持续下去)
唯一写入的值是0和1000,中间没有“灰色区域”。
我的应用程序表现得还不错,有了更新的API(22,23,24,25):
09-17 11:41:09.663 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 11:41:09.672 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 11:41:09.690 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 11:41:09.700 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 11:41:09.717 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 0
09-17 11:41:09.734 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 1
09-17 11:41:09.750 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 2
09-17 11:41:09.769 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 3
09-17 11:41:09.792 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 5
09-17 11:41:09.822 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 8
09-17 11:41:09.840 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 10
09-17 11:41:09.874 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 15
09-17 11:41:09.897 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 18
09-17 11:41:09.922 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 24
09-17 11:41:09.945 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 27
09-17 11:41:09.970 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 35
09-17 11:41:09.991 4534-4534/<MY APPLICATION ID> D/<MY ACTIVITY>: Animation Progress Value: 38
...
与Drawable的另一个ValueAnimator动画(ofAlpha())完全相同的事情:不在API 19上工作,在其他的上工作正常。
为什么会这样?