动画引擎不为视图设置动画

时间:2014-05-12 18:52:12

标签: android

我有以下动画

ValueAnimator colorAnim = ObjectAnimator.ofInt(contentBg, "backgroundColor", /*transparent*/0x0, /*dark*/0xcc000000);
        colorAnim.setDuration(3000);
        colorAnim.setEvaluator(new ArgbEvaluator());
        colorAnim.start();

所以我想要的是将contentBg从透明设置为近乎不透明的黑暗。然而,我得到的只是一个透明的视图,3秒后它立即变暗(动画的最终值)。 我该怎么做才能让它正常工作? 我正在使用nineoldandroids lib。

2 个答案:

答案 0 :(得分:0)

您是否尝试过仅为alpha设置动画?

ValueAnimator colorAnim = ObjectAnimator.ofFloat(contentBg, View.ALPHA, 0, 0.8);
colorAnim.setDuration(3000);
colorAnim.start();
来自here

编辑:似乎ArgbEvaluator评估alpha值存在问题。您可以尝试https://github.com/EaseTheWorld/PaintAnimator/blob/master/src/dev/easetheworld/animator/ArgbEvaluator2.java

中提供的修补版本

答案 1 :(得分:0)

实际上通过将我的问题缩小到动画只是alpha来解决它。 How to set View alpha in lower Api than 11?

相关问题