title: Drawing on the ImageView
body: <p>I am trying to draw on the ImageView (like a simple paint but just on the image). I have created a custom MyImageView class that extends ImageView where I override onDraw. I would like the ImageView to be at the center of the screen.</p>
  
  <p>When I use one layout the image appears in the TOP LEFT CORNER and I can draw on top of it with no problems.</p>
  
  <p><a href="https://i.stack.imgur.com/k6rpg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k6rpg.png" alt="enter image description here"></a></p>
  
  <p>When I use a different layout, the image appears at the center of the screen <strong>BUT</strong> the canvas still remains this small little rectangle at the top left corner. So when I try to draw on the image I can only do it in the top left corner and the changes appear on the image at the center.</p>
  
  <p><a href="https://i.stack.imgur.com/ufnDC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ufnDC.png" alt="enter image description here"></a></p>
  
  <p>In my MainActivity I set:</p>
  
  <pre><code>myImageView = (MyImageView) findViewById(R.id.pdfView);
  
  // I also extract the bitmap myBitmap from the pdf ...
  // and pass it to the ImageView
  myImageView.setImageBitmap(myBitmap);
  
  // and I set the Canvas too:
  Canvas myCanvas = new Canvas(myBitmap);
  myImageView.setMyCanvas(myCanvas);
  </code></pre>
  
  <p>Then here are the crucial parts of the MyImageView:</p>
  
  <pre><code>public class MyImageView extends 
      android.support.v7.widget.AppCompatImageView {
  
      // variables...
  
      public MyImageView(Context context, @Nullable AttributeSet attrs) {
          super(context, attrs);
          setupDrawing();
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          super.onDraw(canvas);
          canvas.drawPath(drawPath, drawPaint);
      }
  
      private void setupDrawing() { //...usual stuff here }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) { //...usual stuff here }
  
      public void setMyCanvas(Canvas canvas) { this.myCanvas = canvas; }
  </code></pre>
  
  <p>Do I have to add/change sth in MyImageView or MainActivity so that the canvas will be only on top of the ImageView or at least stretch across the whole screen?</p>