Hello, I have problems with AnimationDrawable which i use to animate a 'striped' gif file. In fact I have two animations that I want to use in one activity (and they must be used in the same activity). Both animation are build with 7 frames :
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/ android" android:id="@+id/analyse" android:oneshot="false"> <item android:drawable="@drawable/analyse_frame_0" android:duration="50" /> <item android:drawable="@drawable/analyse_frame_1" android:duration="50" /> <item android:drawable="@drawable/analyse_frame_2" android:duration="50" /> <item android:drawable="@drawable/analyse_frame_3" android:duration="50" /> <item android:drawable="@drawable/analyse_frame_4" android:duration="50" /> <item android:drawable="@drawable/analyse_frame_5" android:duration="50" /> <item android:drawable="@drawable/analyse_frame_6" android:duration="50" /> </animation-list> The second one is the same, just different files but also 7 frames. In the onCrate() method of my activity I start the first animation and launch a 15 second timer (the idea is that the first animation is playing when the timer ticks). I use the following code: //The onCreate method of the activity class. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.third); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); layout = (LinearLayout)findViewById(R.id.widget40); analyseImage = (ImageView) findViewById(R.id.ImageView02); analyseImage.setBackgroundResource(R.drawable.analyse_animation); analyseAnimation = (AnimationDrawable) analyseImage.getBackground(); analyseAnimation.start(); MyCount counter = new MyCount(15000,1000);. counter.start(); } Unfortunately this does not work. However when the timer finishes I want to start a second animation and launch a seperate thread. And this works - when I start the animation in the 'onFinish' method of the timer, the animation starts properly: //the onFinish() method of timer. public void onFinish() { layout.setBackgroundResource(R.drawable.id_app4); analyseImage .destroyDrawingCache(); analyseImage .setVisibility(View.GONE); connectImage = (ImageView) findViewById(R.id.ImageView02); connectImage.setBackgroundResource(R.drawable.connect_animation); connectAnimation = (AnimationDrawable) analyseImage.getBackground(); connectAnimation.start(); startThread(connectTh,myConnector); } Unfortunately this does not work so good because it only works when I comment-out the first one - otherwise I get an Exception : 'OutOfMemoryError: bitmap size exceeds VM budget'. As you see I try to release some memory but this does not help. This is a crucial problem, since my application is working in a 'ring' of couple activities. So when I finish the last one it goes back to the first one - it is possible that the activity with animations will be called many times in the life-time of the whole app. So I need to release the memory from the second one as well. So now here are my questions: - why can't I start the first animation instantly after the activity starts and how to do this? - How to release the memory from the animations? Can anyone please help? PS: I am working on Android 1.5 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en