[英]Animate ImageView
Currently I'm developing a game. 目前,我正在开发游戏。
This is the details of my game: User should choose the correct image object. 这是我的游戏的详细信息:用户应选择正确的图像对象。 I want the images to accelerate from left to right.
我希望图像从左向右加速。 and when they reach the end, they should re-appear on the activity again.
当他们到达终点时,他们应该再次出现在活动中。
This is the screenshot of what I'm working on: 这是我正在处理的屏幕截图:
I have 5 imageviews and they should accelerate. 我有5个imageview,它们应该加速。 Do you have sample code for this type of animation?
您是否有此类动画的示例代码? Any help is truly appreciated.
任何帮助,我们都感激不尽。 Thanks in advance!
提前致谢!
EDIT: Tried doing this: 编辑:尝试这样做:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromXDelta="-100%p"
android:toXDelta="0%"
android:duration="2000"/>
</set>
But it just slides from left, and no continuation of animation.. 但是它只是从左滑动,没有动画的延续。
You can try to use Frame Animation : 您可以尝试使用帧动画 :
In your java file : 在您的java文件中:
imageView.setBackgroundResource(your Resource);
AnimationDrawable animte = (AnimationDrawable) imageView.getBackground();
animte.start();
Probably, this will help you . 可能会帮到您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.