Android 上的倒车动画?
因此,如果我有一个像这样的平移动画
Animation anim = new TranslateAnimation(0, 0, 0, OFFSET);
anim.setDuration(1000L);
anim.setAnimationListener(listener);
anim.setFillAfter(true);
,我将其应用到文本切换器,以便给定偏移量,文本切换器将从位置 A 向上或向下移动。
由于 setfillafter,我的文本切换器将在动画结束后停留在给定位置 B。然后我怎样才能从位置 B 反转动画并返回到位置 A?
总体问题
所以我将文本切换器向下然后向上翻译,但是当然,setfillafter 只翻译视图的位图而不是视图本身,所以这可能不是最好的方法。我也尝试过制作动画,然后偏移视图,但这看起来有点问题。所以基本上,我想要一个视图(文本切换器),向下滑动/滑动会将其向下移动,并在向下时触摸(onClick)将其向上移动(相同的动画相反)。我该怎么做?
我知道如何执行滑动/滑动和 onClick 操作,但不知道如何实现正确的动画。
So if I have a translation animation like
Animation anim = new TranslateAnimation(0, 0, 0, OFFSET);
anim.setDuration(1000L);
anim.setAnimationListener(listener);
anim.setFillAfter(true);
and I apply this to a textswitcher so that given a offset, the textswitcher will move from a location, A, up or down.
My textswitcher will stay at a given location, B, after the animation due to the setfillafter. How can I then from that location, B, reverse the animation and go back to location, A?
The Overall Question
So I'm translating a textswitcher down and then up, but of course, setfillafter only translates the bitmap of the view and not the view itself, so this may not be the best approach. I've also tried to do an animation and then offset of the view, but that looks glitchy. So basically, I want a view(textswitcher) which a swipe/fling down will move it down and touching(onClick) it when it's down will move it back up (same animation reversed). How can I do this?
I know how to do the swipe/fling and onClick stuff, just not how to implement the correct animation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可能需要考虑添加一个触摸监听器来查看您最后一次触摸它的位置,如果上面以恒定的动画向上移动。这是如果我正确理解这个问题的话。
Perhaps you may want to consider adding an on touch listener to see where you touched it last, If above move up with a constant animation. This is if im understanding the question correctly.