xml animations | SoloLearn: Learn to code for FREE!

+2

xml animations

Hi! I got two animations. One I want to show one time and the other one infinite... It's probably easy, but I don't know how to do that... That's my xml-file: <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> Todo: RUN one time: <item android:drawable="@drawable/animation_1_1" android:duration="100"/> <item android:drawable="@drawable/animation_1_2" android:duration="100"/> <item android:drawable="@drawable/animation_1_3" android:duration="100"/> <item android:drawable="@drawable/animation_1_4" android:duration="100"/> stop Todo: RUN Infinite: <item android:drawable="@drawable/animation_2_1" android:duration="100"/> <item android:drawable="@drawable/animation_2_1" android:duration="100"/> <item android:drawable="@drawable/animation_2_1" android:duration="100"/> <item android:drawable="@drawable/animation_2_1" android:duration="100"/> </animation-list>

11/9/2020 11:44:24 AM

Fu Foy

1 Answer

New Answer

+5

Animation animation=AnimationUtils.loadAnimation(getApplicationContex(),R.anim.your_anim); //Run only one time animation.setRepeatCount(1); Your view.startAnimation(animation); //Run infinite animation.setRepeatCount(Animation.INFINITE); Your view.startAnimation(animation); hint: also can be done through xml, Android:repeatCount="infinite".