Recommended Android Animation Method

I searched the Internet to find out more about character animation in Android, but did not fully understand it. I ask, maybe you could give me some tips or hints on how to do this in the best way.

Scenario

Imagine 5 drawings (say 5 human heads). I need to revive them. By animation, I mean making my eyes blink, smile, laugh, etc. I am currently working on creating raster resources for each animation. For example, for a blinking animation, basically I have 3 images, one with eyes open, one with eyes closed, one with eyes closed. I need to revive the character in order to use all these 3 images.

This is all the animation I need, nothing more interesting. Any suggestions on where to start?

+3
source share
2 answers
AnimationDrawable frameAnimation;
frameAnimation = (AnimationDrawable) addselection.getBackground();

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    frameAnimation.start();
    super.onWindowFocusChanged(hasFocus);
}

add drawable using this xml type

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item android:drawable="@drawable/add_selection0001" android:duration="50" />
    <item android:drawable="@drawable/add_selection0002" android:duration="50" />
    <item android:drawable="@drawable/add_selection0003" android:duration="50" />
    <item android:drawable="@drawable/add_selection0004" android:duration="50" />
    <item android:drawable="@drawable/add_selection0005" android:duration="50" />
    <item android:drawable="@drawable/add_selection0006" android:duration="50" />
    <item android:drawable="@drawable/add_selection0007" android:duration="50" />
    <item android:drawable="@drawable/add_selection0008" android:duration="50" />
    <item android:drawable="@drawable/add_selection0009" android:duration="50" />
    <item android:drawable="@drawable/add_selection0010" android:duration="50" />
    <item android:drawable="@drawable/add_selection0011" android:duration="50" />
    <item android:drawable="@drawable/add_selection0012" android:duration="50" />
    <item android:drawable="@drawable/add_selection0013" android:duration="50" />
    <item android:drawable="@drawable/add_selection0014" android:duration="50" />
    <item android:drawable="@drawable/add_selection0015" android:duration="50" />
    <item android:drawable="@drawable/add_selection0016" android:duration="50" />
    <item android:drawable="@drawable/add_selection0017" android:duration="50" />
    <item android:drawable="@drawable/add_selection0018" android:duration="50" />
    <item android:drawable="@drawable/add_selection0019" android:duration="50" />
    <item android:drawable="@drawable/add_selection0020" android:duration="50" />
 </animation-list>

different images are set here for your sequence animation.set this drawable as your background in imageview

+2
source

Just for you, you can try Frame Animation, this is part of the basic Animation package in Android, there is a relatively simple example on the official documentation website: http://developer.android.com/guide/topics/resources/animation-resource.html# Frame .

, SurfaceView Canvas () . , , . -, , , ( - ) SurfaceView.

+2

Source: https://habr.com/ru/post/1784493/


All Articles