I'm pretty new to Android programming, and I've looked around but haven't been able to find a clear-cut answer. I need to slowly animate an image by switching it with anothe, like a sprite. If anyone can help, it seems like it should be really simple. Thanks!
Once you have your folder with all your images, go to Xcode, select your project assets catalog, and drag-and-drop the animation folder. To make sure everything stay organized, enable the "Provide Namespace" option. It will make assets accessible from "FolderName/ImageName" instead of "ImageName" in your swift files.
Animating an image change with Swift is quite simple, all we need to do is use UIView. transition . To do this I have created a new project and added a UIImageView to my Main.
One way to animate Drawables is to load a series of Drawable resources one after another to create an animation. This is a traditional animation in the sense that it is created with a sequence of different images, played in order, like a roll of film. The AnimationDrawable class is the basis for Drawable animations.
You'll probably want to use a TransitionDrawable http://developer.android.com/reference/android/graphics/drawable/TransitionDrawable.html
Drawable[] layers = new Drawable[2];
layers[0] = //your first drawable
layers[1] = //your second drawable
TransitionDrawable transition = new TransitionDrawable(layers);
myImageView.setImageDrawable(transition);
transition.startTransition(1500);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With