Define zoom/pan start position with KenBurnsView

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 15:48:26

You need to implement your own TransitionGenerator and override generateNextTransition() from where you must return a Transition object.

The generateNextTransition() method takes:

  1. RectF drawableBounds: the bounds of the drawable that is set to the KenBurnsView;

  2. RectF viewport the bounds of the KenBurnsView object.

The Transition constructor takes:

  1. RectF srcRect: a subrectangle of the drawable that will fill the whole KenBurnsView when the transition starts (illustrated below):

Illustration from Wikipedia

  1. RectF dstRect: a subrectangle of the drawable that will fill the whole KenBurnsView when the transition ends;

  2. long duration: the duration, in milliseconds, of the transition.

  3. 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!