Animate image's saturation

风格不统一 提交于 2019-12-05 06:03:53

It certainly could be achieved with a ValueAnimator:

ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
animation.setDuration(1000);
animation.addUpdateListener(new AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
        matrix.setSaturation(animation.getAnimatedFraction());
    }
});
animation.start();

You have to animate it yourself!

Should not be that hard.

See the ColorMatrix example in the API's demos folder.

http://alvinalexander.com/java/jwarehouse/android-examples/platforms/android-2/samples/ApiDemos/src/com/example/android/apis/graphics/ColorMatrixSample.java.shtml

You can extend Drawable and increment a value in the onDraw method and then set the filter accordingly.

You get the animation by calling invalidate() every few ms in onDraw. Be sure to slow down the iterations by puting the thread to sleep. Thread.sleep(40); for 25 fps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!