简体   繁体   English

动画ImageView

[英]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.

相关问题 我的ImageView的动画高度 - Animate Height of my ImageView 调整ImageView的动画大小以适应另一个ImageView的大小 - Animate resizing of ImageView to size of another ImageView 在WindowManager中对ImageView进行动画处理-Android - Animate ImageView inside WindowManager - Android 在整个图像上对ImageView进行动画处理 - Animate ImageView across wide image 如何为我的android imageView设置动画以扩大尺寸? - how to animate my android imageView to scale larger? 如何从左开始为ImageView设置动画以填充屏幕? - How to animate an ImageView from left to fill the screen? 对活动中的imageview进行动画处理,然后从底部将片段带入活动中:Android - Animate an imageview out of the activity and bring a fragment into the activity from the bottom: Android 在继续其余代码之前,等待ImageView.animate()结束 - Waiting for ImageView.animate() to end before proceeding with the rest of the code 使用像ScaleAnimation这样的ViewAnimator时,如何在ImageView中对全分辨率图像进行动画处理? - How can I animate the full-resolution image in an ImageView when using a ViewAnimator like ScaleAnimation? 尝试在空对象引用上调用虚拟方法“android.view.ViewPropertyAnimator android.widget.ImageView.animate()” - Attempt to invoke virtual method 'android.view.ViewPropertyAnimator android.widget.ImageView.animate()' on a null object reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM