Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

android - Add transition to an AnimationDrawable

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 on that part. There is the AnimationDrawable, that switch between pictures, but it doesn't animate the switch. There is the TransitionDrawable, that cross fade between two pictures, but no more than two.

Hell.

I looked for some solution on Google, but no luck on that part. So I'm thinking about implementing my own drawable to achieve such a thing. Would any of you have any pointers ?

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...