Detailed explanation of Android frame animation examples
For Android frame animation, it can be roughly understood as pictures to switch in a certain order, so that when several consecutive pictures are a group of animations, they can be connected and watched as a small movie. You know
OK, let's put it here, and the topic is getting started. Due to product requirements, I need to make a dynamic switching style of sound speakers. The first thing I thought was frame animation switching, and then I found that it was Baidu's information and found that there was too much information on the Internet now that was pasted by copy. All the mistakes were wrong. For this situation, I just want to say, made, a bunch of garbage.
So today I will take you into the Android correct frame animation address.
Step 1: Create drawable in the res file directory:(In Android studio, it must be in this directory, not under anim, otherwise an error will occur)
<animation-list xmlns:andro android:oneshot="false"> <item android:drawable="@drawable/icon_speaking_white_left_01" android:duration="200" /> <item android:drawable="@drawable/icon_speaking_white_left_02" android:duration="200" /> <item android:drawable="@drawable/icon_speaking_white_left_03" android:duration="200" /> </animation-list>
android:oneshot="false"
This code means that the carousel is always played, and true means that it is played only once.
Step 2: QuoteMost of the articles are wrong here, which may be due to the age of time. The correct way to write it is as follows:
image = (ImageView) findViewById(.iv_sound);
(); AnimationDrawable animationDrawable = (AnimationDrawable) (); ()
If you have any questions, please leave a message or go to the community of this site to exchange and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!