TransitionDrawable with xml drawable - fading to xml drawable doesn't work properly

480 Views Asked by At

I have a transition drawable fading from a png to an xml drawable (a simple gradient). When I call startTransition(int time) the image seems to fade strangely, leaving the previous drawable visible in the background, almost as if it only fades half way. It might be worth noting it seems to work without issue on lollipop (i've just seen this happen on kitkat phones I've tested so far).

Is there something I need to do to the xml drawable to make it function properly?

1

There are 1 best solutions below

1
bonnyz On

Before calling startTransition(int time) try to invoke:

yourTransitionDrawable.setCrossFadeEnabled(true);

This seems to be necessary when you want a real cross-fade transition (and not a fade-in one).