如何通过触摸控制动画 [英] How to control an animation via touch

查看:179
本文介绍了如何通过触摸控制动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用磁盘浏览文件的应用程序,例如: http://dl.dropbox.com/u/8051037/disk_ab1.png

I'm creating an app that uses a disk to browse files and such, like this: http://dl.dropbox.com/u/8051037/disk_ab1.png

我想让它能够随着用户旋转而旋转,而且我知道我需要使用RotateAnimation,但是我不知道如何使其顺着手指滑动.

I want to make it be able to spin as the user turns it, and I know I need to use a RotateAnimation, but I can't figure out how to make it follow the finger.

推荐答案

我认为您应该使用自定义视图,请参见此示例来旋转球:

I think you should use a custom view, see this examle which rotates a ball: How can I use the animation framework inside the canvas?

然后,您可以使用运动事件来控制旋转角度:

then you can use motion event to control the angle of rotation: Android firing onTouch event for multiple ImageViews

自定义视图可以是透明的,因此您可以将其与布局中的其他样式结合起来.

Custom view can be transparent so you can combine it with other veiws in your layout.

这篇关于如何通过触摸控制动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆