Animate fading Background Drawable dynamically

686 views Asked by At

I have a drawable (Linear Layout) which has a dynamic color defined as background.

I want to fade the current color to a highlight-color and then fade back to a final-color, which can be different from the start-color the transition to highlight color should be 0.4s long and from highlight to final 0.2s

I tried it with the AnimationDrawable but without success, because this doesn't really support fading. my current code:

AnimationDrawable animation = new AnimationDrawable();
animation.addFrame(context.getResources().getDrawable(highlightDrawableId), 400);
animation.addFrame(newBackground, 200);

animation.setEnterFadeDuration(200);
animation.setOneShot(true);
layout.setBackground(animation);
animation.start();

Is there any way how I can make this work?

0

There are 0 answers