1

So I want to create some animating ImageViews as described in :

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

However I have been searching but couldn't find anything on this subject. Is it possible to have an item in the animation-list be an image inside an expansion APK file(a zip file). I already know how to get an image out of an Expansion APK file but I want to know if I can somehow get it into the animation-list, either programmatically or just referenced somehow in the XML file.

So my question is if this is possible? And (if possible) how I would go about doing this?

jww
  • 97,681
  • 90
  • 411
  • 885

1 Answers1

0

you can use different frame of image put in the drawable folder named first.png,second.png etc for animation effect and load it after certain interval of time.

create animation_list.xml and put it.

<?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/first" android:duration="210" />
    <item android:drawable="@drawable/second" android:duration="210" />
    <item android:drawable="@drawable/third" android:duration="210" />
    <item android:drawable="@drawable/fourth" android:duration="210" />
    <item android:drawable="@drawable/fifth" android:duration="210" />
    <item android:drawable="@drawable/sixth" android:duration="210" />

</animation-list>

Then in MainActivity code is.create imageview named yourImageView in the activity_main xml

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;

public class MainActivity extends Activity {

    private AnimationDrawable frameAnimation;
    private ImageView view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        // Type casting the Image View
        view = (ImageView) findViewById(R.id.yourImageView);

        // Setting animation_list.xml as the background of the image view
        view.setBackgroundResource(R.drawable.animation_list);

        // Type casting the Animation drawable
        frameAnimation = (AnimationDrawable) view.getBackground();
        frameAnimation.start();
    }
}
rafi
  • 364
  • 3
  • 9
  • Hey! Thanks for answering! However, this was already known to me. If we take the situation you put down here but now instead of in the drawable, first.png,second.png etc are now stored in an Expansion APK (a Zip file lets say main.1.com.example.app.obb). Can I still make it work? I don't mind unpacking the needed files somewhere. – DeviousSiddy Dec 19 '14 at 06:52