定义缩放/平移启动位置KenBurnsView [英] Define zoom/pan start position with KenBurnsView
问题描述
我与图书馆 KenBurnsView 的工作,我有一个问题:
I'm working with the library KenBurnsView and I have a problem:
概述或这个漂亮的图书馆说以下内容:具有高度可扩展:可以定义矩形如何进行缩放和平移,将产生
而这正是我想做的事情,但我不知道究竟如何。
the overview or this nice library says the following: "Highly extensible: you can define how the rectangles to be zoomed and panned will be generated" and that's exactly what I want to do but I don't know exactly how.
我希望能够告诉从我的图像的指定区域(一RectF我presume),缩放或平移图书馆。
我想我要实现我自己的TransitionGenerator和编写自定义generateNextTransition()mtehod但我不知道该怎么办里面。
I would like to be able to tell the library to zoom or pan from a specified region (a RectF I presume) of my image. I think I have to implements my own TransitionGenerator and write a custom generateNextTransition() mtehod but I don't know what to do inside.
谁能帮我?
感谢。
阿德里安
Thanks. Adrian
推荐答案
您需要实现自己的 TransitionGenerator
并重写 generateNextTransition()$ C $从那里你必须返回一个
过渡
对象C>。
You need to implement your own TransitionGenerator
and override generateNextTransition()
from where you must return a Transition
object.
的 generateNextTransition()
方法需要:
-
RectF drawableBounds
:被设置为可绘制的边界的KenBurnsView
;
RectF drawableBounds
: the bounds of the drawable that is set to theKenBurnsView
;
RectF视
的 KenBurnsView
对象的范围。
的过渡
构造函数:
-
RectF srcRect
:可绘制的一个子矩形,将填补整个KenBurnsView
时的过渡启动(如下图所示):
RectF srcRect
: a subrectangle of the drawable that will fill the wholeKenBurnsView
when the transition starts (illustrated below):
RectF dstRect
:提拉,将填补整个的一个子矩形 KenBurnsView
时的过渡结束
RectF dstRect
: a subrectangle of the drawable that will fill the wholeKenBurnsView
when the transition ends;
持续时间长
:持续时间,以毫秒为单位的过渡
long duration
: the duration, in milliseconds, of the transition.
插补器插
:内插实例将定义运动的性质(可能是一个 AccelerateDecelerateInterpolator
, LinearInterpolator
,等);
Interpolator interpolator
: an interpolator instance that will define the nature of the movement (may be an AccelerateDecelerateInterpolator
, LinearInterpolator
, etc.);
它可能我是个好主意,以节省 dstRect
如果你渴望被用作 srcRect
在接下来的过渡每一个过渡,从过去的过渡已停止的地方开始。这正是在 RandomTransitionGenerator
一样。请记住, srcRect
和 dstRect
可以有不同的大小(但两者应的subrectangles drawableBounds
如果你想保留的图像场景所有的时间)。他们两个都有视口的相同的纵横比是很重要的
。
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
.
这篇关于定义缩放/平移启动位置KenBurnsView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!