Add transition to an AnimationDrawable

后端 未结 2 453
傲寒
傲寒 2020-12-11 02:18

I have a set of 10 images, and I want to create an animation where I cross fade between them. I\'ve been looking into built-in Drawable to achieve such a thing, but no luck

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 02:39

    Not sure if you found an answer to this, but I had the same problem and ended up building my own class based on TransitionDrawable.

    Usage:

    CyclicTransitionDrawable ctd = new CyclicTransitionDrawable(new Drawable[] { 
      drawable1, 
      drawable2, 
      drawable3, 
      ... 
    });
    
    imageView.setImageDrawable(ctd);
    
    ctd.startTransition(1000, 3000) // 1 second transition, 3 second pause between transitions.
    

    The code for the CyclicTransitionDrawable is available on Github.

提交回复
热议问题