android – 动画图像的饱和度

android – 动画图像的饱和度,第1张

概述是否可以随时间动画图像饱和度(例如png)?例如,从灰度到全彩.如果我可以使用插值器. 我已经看过EffectFactory和ColorMatrix类,但是我无法将它们与动画/过渡相结合. 例如.在Drawable drawable上应用灰度饱和度: ColorMatrix matrix = new ColorMatrix();matrix.setSaturation(0);ColorMa 是否可以随时间动画图像的饱和度(例如png)?例如,从灰度到全彩.如果我可以使用插值器.

我已经看过EffectFactory和colorMatrix类,但是我无法将它们与动画/过渡相结合.

例如.在Drawable drawable上应用灰度饱和度:

colorMatrix matrix = new colorMatrix();matrix.setSaturation(0);colorMatrixcolorFilter filter = new colorMatrixcolorFilter(matrix);drawable.setcolorFilter(filter);

并在以后完全饱和:

matrix.setSaturation(1);

对于任何感兴趣的人,我的完整解决方案基于Simon的答案:

final colorMatrix matrix = new colorMatrix();final Drawable drawable = ... ;ValueAnimator animation = ValueAnimator.offloat(0f,1f);animation.setDuration(1000);//   animation.setInterpolator();animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {    @OverrIDe    public voID onAnimationUpdate(ValueAnimator animation) {        matrix.setSaturation(animation.getAnimatedFraction());        colorMatrixcolorFilter filter = new colorMatrixcolorFilter(matrix);        drawable.setcolorFilter(filter);    }});animation.start();
解决方法 使用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();
总结

以上是内存溢出为你收集整理的android – 动画图像的饱和度全部内容,希望文章能够帮你解决android – 动画图像的饱和度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1138923.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存