You need to implement your own TransitionGenerator
and override generateNextTransition()
from where you must return a Transition
object.
The generateNextTransition()
method takes:
RectF drawableBounds
: the bounds of the drawable that is set to the KenBurnsView
;
RectF viewport
the bounds of the KenBurnsView
object.
The Transition
constructor takes:
RectF srcRect
: a subrectangle of the drawable that will fill the whole KenBurnsView
when the transition starts (illustrated below):
Illustration from Wikipedia
RectF dstRect
: a subrectangle of the drawable that will fill the whole KenBurnsView
when the transition ends;
long duration
: the duration, in milliseconds, of the transition.
Interpolator interpolator
: an interpolator instance that will define the nature of the movement (may be an AccelerateDecelerateInterpolator
, LinearInterpolator
, etc.);
It might me a good idea to save dstRect
to be used as srcRect
in the next transition if you desire that every transition will start from the place the last transition has stopped. That's exactly what the RandomTransitionGenerator
does. Keep in mind that srcRect
and dstRect
can have different sizes (but both should be subrectangles of drawableBounds
if you want to keep the image in scene all the time). It's important that both of them have the same aspect ratio of viewport
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…