title: Scale Bitmap using drawBitmap
body: <p>Basically I have 640 x 480 image and I want to scale and draw it using <em>drawBitmap</em>. For simplicity lets just say I have 854 x 480 android screen. Here is my code</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends Activity
  {
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
      super.onCreate(savedInstanceState);
      setContentView(new MainLayout(this));
    }
  }
  class MainLayout extends RelativeLayout
  {
    public MainLayout(Context context)
    {
      super(context);
      setWillNotDraw(false);
    }
    @Override
    public void onDraw(Canvas canvas)
    {
      super.onDraw(canvas);
      Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.background);
      bitmap = Bitmap.createScaledBitmap(bitmap, 854, 480, true);
      canvas.drawBitmap
      (
        bitmap,
        null,
        new Rect(0, 0, 854, 480),
        null
      );
    }
  }
  </code></pre>
  
  <p>The result is different than what I want. Any suggestion?</p>