title: Animation causing out of memory exception
body: <p>My application provides an <code>outofmemory</code> exception when an animation starts to play. What can I do?
  The images in animation combined have a size of 512kb, that's 10 images.</p>
  <p>My activity class is <code>button_anime</code>.</p>
  <pre><code> public class Button_Anime extends Activity{
  
  private static int SPLASH_TIME_OUT = 500;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_splash_about);
      ImageView loading =(ImageView) findViewById(R.id.iVArcRail_2);
      loading.setBackgroundResource(R.drawable.about_button_anime);
      AnimationDrawable load =(AnimationDrawable)loading.getBackground();
      load.start();
      new Handler().postDelayed(new Runnable() {
                 
          @Override
          public void run() {
                 Intent i = new Intent(Button_Anime.this, Home.class); 
              startActivity(i);
              finish();
          }
      }, SPLASH_TIME_OUT);
    }
   }
  </code></pre>
  <p>My <code>activity_splash_about.xml</code></p>
  <pre><code>  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  android:background=&quot;@drawable/withoutlogo&quot; &gt;
  
  &lt;ImageView
      android:id=&quot;@+id/imageView1&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;70dp&quot;
      android:layout_alignParentTop=&quot;true&quot;
      android:layout_centerHorizontal=&quot;true&quot;
      android:layout_marginBottom=&quot;10dp&quot;
      android:layout_marginTop=&quot;10dp&quot;
      android:background=&quot;@drawable/logoline&quot; /&gt;
  
  &lt;ImageView
      android:id=&quot;@+id/iVArcRail_2&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_below=&quot;@+id/imageView1&quot;/&gt;
   &lt;/RelativeLayout&gt;
  </code></pre>
  <p>This is the animation file. <code>about_button_anime</code></p>
  <pre><code>  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    &lt;animation-list xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; 
    android:oneshot=&quot;false&quot; &gt;
    &lt;item
        android:drawable=&quot;@drawable/ab1&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab2&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab3&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab4&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab5&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab6&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab7&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab8&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab9&quot;
        android:duration=&quot;50&quot;/&gt;
    &lt;item
        android:drawable=&quot;@drawable/ab10&quot;
        android:duration=&quot;50&quot;/&gt;
    
    &lt;/animation-list&gt;
  </code></pre>
  <p>And this is my log cat.</p>
  <pre><code> FATAL EXCEPTION: main
   Process: com.quinoid.thomasinternational, PID: 1514
   java.lang.OutOfMemoryError
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
   at android.content.res.Resources.loadDrawable(Resources.java:2110)
   at android.content.res.Resources.getDrawable(Resources.java:700)
   at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282)
   at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
   at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
   at android.content.res.Resources.loadDrawable(Resources.java:2092)
   at android.content.res.Resources.getDrawable(Resources.java:700)
   at android.view.View.setBackgroundResource(View.java:15303)
   at com.quinoid.thomasinternational.Button_Anime.onCreate(Button_Anime.java:19)
   at android.app.Activity.performCreate(Activity.java:5231)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
   at android.app.ActivityThread.access$800(ActivityThread.java:135)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5017)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
   at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  <p>How can I get this animation running?</p>
  <p>I have already provided <code>largeHeap=&quot;true&quot;</code>.</p>