title: Android : Lagging for a TranslateAnimation
body: <p>I have to realize a "scan bar" animation, making an animation of translation (a bit like the google goggles app). It's a bar picture (custom view), which cross my surfaceview from left to right.</p>
  
  <p>I did something that is close to my expectations, except that the animation lagging :(</p>
  
  <p>This is a part of my XML :</p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/layoutCamera"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="8" &gt;
  
      &lt;SurfaceView 
          android:id="@+id/surfaceView"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_gravity="top" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is my custom wiew :</p>
  
  <pre><code>class ScannerView extends View 
  {
  private Bitmap scanBar;
  private int sizeBarW;
  private int sizeBarH;   
  
  public ScannerView(Context context, int heightParent) 
  {
      super(context);     
  
      //init size
      sizeBarW = 5;
          //I adjust the height of the bar to my surfaceview
      sizeBarH = heightParent;
  
      //prepare bitmap
      scanBar = prepareBitmap(getResources().getDrawable(R.drawable.scan_bar), sizeBarW,
              sizeBarH);      
  }
  
  private static Bitmap prepareBitmap(Drawable drawable, int width, int height) 
  {
      Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      drawable.setBounds(0, 0, width, height);
      Canvas canvas = new Canvas(bitmap);
      drawable.draw(canvas);
      return bitmap;
  }
  
  @Override
  protected void onDraw(Canvas canvas) 
  {
      canvas.drawBitmap(scanBar, 0, 0, null);
  }
  }
  </code></pre>
  
  <p>And this is my animation function (called on surfaceChanged() from my activity class):</p>
  
  <pre><code>private void LaunchAnimation()
  {
      // 1 - view
      mScanBar = new ScannerView(this, surfaceView.getHeight());
      addContentView(mScanBar, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  
      // 2 - Animation
      Animation animTranslation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 1.0f,
                                                         Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
      animTranslation.setDuration(5000);
      animTranslation.setRepeatCount(Animation.INFINITE);
      mScanBar.startAnimation(animTranslation);
  }
  </code></pre>
  
  <p>I am beginner in android programming and I'm not sure I do it the best way... :?</p>
  
  <p>Thank you to help me to resolve this lagging/slow-down problem. :)</p>