title: Draw with a Canvas over an Image in Android/Java
body: <p>I try to draw on a Canvas, where the background is an loaded Image in Android.
  It works just fine without the backgroundimage:</p>
  
  <pre><code>background = (ImageView)view.findViewById(R.id.Background);
  Bitmap bitmap = Bitmap.createBitmap(canvasSize,canvasSize,Bitmap.Config.ARGB_8888);
  canvas = new Canvas(bitmap);
  background.setImageBitmap(bitmap);
  </code></pre>
  
  <p>Im passing that canvas to another class and draw on it. That works fine.</p>
  
  <p>But when I do this:</p>
  
  <pre><code>background = (ImageView)view.findViewById(R.id.Background);
  Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); //Just to test
  
  canvas = new Canvas(bitmap); 
  //or this
  canvas = new Canvas(bitmap.copy(Bitmap.Config.ARGB_8888, true));
  
  background.setImageBitmap(bitmap);
  </code></pre>
  
  <p>It doesn't draw over the image, so you can't see the point.
  Here is the code from the other class where I use this canvas to draw:</p>
  
  <pre><code>canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
  canvas.drawCircle( (float)sObject.getSideGforce()*mult+add, 
  (float)sObject.getFrontRearGforce()*mult+add, 15*V.LOGICAL_DENSITY, dot);                                                                                                                          
  </code></pre>
  
  <p>My goal is to create a Canvas with a custom size which has an image as a background where I can draw on.
  Its a Gforce Display, so the Image will be some circles with numbers and the canvas will draw a point over it so you can see how many Gs you are pulling. Like I already said it works perfectly without the background. And I dont want to redraw the background every single time I reposition the point. So the background should be static and the point should on the canvas is dynamic ( at 100hz ).
  Thanks in advance.</p>
  
  <p>SOLUTION:
  It works with this code.</p>
  
  <pre><code>view.setBackgroundResource(R.drawable.ic_launcher);
  </code></pre>
  
  <p>I just had to set the Background of my view. It stretches the image to the size of my fragment, but thats OK.</p>