I'm having some trouble with frame animation: I have an app with an ImageView on which I would like to show some frame-by-frame animation. My code is as follows: Main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/spotim000" />
</LinearLayout>
and my java is:
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
public class AnimationTestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView imageView1 = (ImageView) findViewById(R.id.imageView1);
imageView1.setImageResource(R.drawable.spotlights);
}
}
spotlights.xml:
<?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/spotim000" android:duration="50" />
<item android:drawable="@drawable/spotim001" android:duration="50" />
<item android:drawable="@drawable/spotim002" android:duration="50" />
...
<item android:drawable="@drawable/spotim099" android:duration="50" />
<item android:drawable="@drawable/spotim100" android:duration="50" />
</animation-list>
I didn't include the code that starts the animation - because the problem isn't there. When I launch this code using the emulator or using my HTC Desire - the code runs prefectly. However, when I run it on a Samsung Galaxy S2 - I get this error:"java.lang.outofmemoryerror bitmap size exceeds vm budget on bitmap"
When I remove some of the frames (leaving lets say 20 out of the original 101) it works fine also on the galaxy. But I need all the frames and I can't really get why it works on a HTC Desire but not on the much stronger Galaxy S2
I've been looking on other posts with similar problem but the only one I could find is this un-answered post: Android Animation (XML) Giving OutOfMemoryError: bitmap size exceeds VM budget (only on Motorola Droids?)
Anyone has any insights on this matter?
Thanks a lot, Shai :)