0

I would like to add some animation to an Android application, in which an icon would move from left to right along a horizontal line.

Our graphic designer suggested animated GIFs or MOV files, but we're not sure if these are the right formats for Android - especially in terms of file sizes.

Which animation file formats are supported by Android? Is there an official or recommended format by Google?

  • Hi, could you tell us what you tried that didn't work? Always good to show some effort, and your chances for a good answer increase. If you have any questions, please see the help center or ping one of us in chat once your reputation is sufficient (20). Keep contributing and enjoy the site! – KMSTR Apr 27 '15 at 12:28
3

A PNG Sequence is often used in my experience.

Example:

<!-- Animation frames are wheel0.png -- wheel5.png files inside the
 res/drawable/ folder -->
 <animation-list android:id="@+id/selected" android:oneshot="false">
    <item android:drawable="@drawable/wheel0" android:duration="50" />
    <item android:drawable="@drawable/wheel1" android:duration="50" />
    <item android:drawable="@drawable/wheel2" android:duration="50" />
    <item android:drawable="@drawable/wheel3" android:duration="50" />
    <item android:drawable="@drawable/wheel4" android:duration="50" />
    <item android:drawable="@drawable/wheel5" android:duration="50" />
 </animation-list>

from: http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html

2

Most likely this would be done in code using a custom animation. See Android's developer site for more info: Defining Custom Animations. Here, for example, is the code to morph from one shape to another, from AnimatedVectorDrawable:

<set xmlns:android="http://schemas.android.com/apk/res/android">
 <objectAnimator
     android:duration="3000"
     android:propertyName="pathData"
     android:valueFrom="M300,70 l 0,-70 70,70 0,0   -70,70z"
     android:valueTo="M300,70 l 0,-70 70,0  0,140 -70,0 z"
     android:valueType="pathType"/>

  • Hey KJP. Could you please include the relevant parts of the link in your answer itself so that it will remain useless if the link goes down or changes? – Zach Saucier Apr 27 '15 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.