Kerem
Kerem

Reputation: 1553

KenBurnsView creating smooth custom animation

I'm using the KenBurnsView library in here

But transition is not smooth and I don't know how to use the following code noted on github:

RandomTransitionGenerator generator = new RandomTransitionGenerator(duration, interpolator);
kbv.setTransitionGenerator(generator);

Can anyone help me how to create a smooth transition?

Upvotes: 1

Views: 1536

Answers (1)

Kushal Sharma
Kushal Sharma

Reputation: 5973

So you already have a KenBurnsView type object i.e kvb. To add a custom transition as the docs says and you also suggest.

Make

RandomTransitionGenerator generator = new RandomTransitionGenerator(duration, interpolator);

RandomTransitionGenerator is a class already included in the lib.

It takes 2 parameters :

1) duration i.e in miliseconds (usualy that the case)

2) interpolator - it is more like the effect of animation or rate of change of an animation.

We need to make an object of type Interpolator and use it like :

AccelerateDecelerateInterpolator ACCELERATE_DECELERATE = new AccelerateDecelerateInterpolator();
RandomTransitionGenerator generator = new RandomTransitionGenerator(10000, ACCELERATE_DECELERATE);
//duration = 10000ms = 10s and interpolator = ACCELERATE_DECELERATE
kbv.setTransitionGenerator(generator); //set new transition on kbv

the docs also adds that if you need more customization you can make your own TransitionGenerator class like RandomTransitionGenerator

Upvotes: 4

Related Questions