title: set the canvas size - Android
body: <p>I want to keep the same size of the bitmap for the canvas, because when I add the custom view to the LinearLayout shows the canvas with different size and I want to set the size of the canvas like bitmap object.</p>
  
  <p>Part of the code:</p>
  
  <pre><code>public class TESTActivity extends Activity {    
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          LinearLayout l = new LinearLayout(this);
          l.setOrientation(1);
          Button b1 = new Button(this);
          Button b2 = new Button(this);
          View mV = new MyView(this);        
          l.addView(b1);
          l.addView(b2);
          l.addView(mV);       
          setContentView(l);
  
      }
  
  
      public class MyView extends View {
  
  
          public MyView(Context c) {
              super(c);
              mBitmap = Bitmap.createBitmap(480, 300, Bitmap.Config.ARGB_8888);
              mCanvas = new Canvas(mBitmap);
              ...
          }
          ...
      }
  }
  </code></pre>