title: Optimizing paging between ImageViews in Android?
body: <p>For the application I'm currently working on, I created something like <code>ImageSwitcher</code> for multiple images (imagine iPhone's <code>UIScrollView</code> with paging enabled).</p>
  
  <p>At first, I hard coded some <code>ImageViews</code> and loaded their drawable resources on creation/inflation, but after some tweaks (and what I thought were improvements), I reduced the needed views to 3, of which 2 are <code>ImageViews</code> used for displaying of the current page and animating between current and new page.</p>
  
  <p>With this change, I began to use <code>setImageResource</code>/<code>setImageDrawable</code> for the dynamic loading of the new image in my 2 <code>ImageViews</code> before sliding through pages (I am using PNG files, sized for HVGA displays).</p>
  
  <p>To my disappointment, the performance got worse, to the extent of feeling some lag when sliding faster through the pages.
  A quick look in <code>TraceView</code> revealed that 17.4% of total time while using the app, over 5 times more than the next heavy method, was consumed from <code>BitmapFactory.nativeDecodeAsset</code>, called by my dynamic setting of drawable resource.</p>
  
  <p>I'm thinking of ways to circumvent this, and I want to do it in the best way possible, so any suggestions are welcome.</p>