title: How to add a Marker/Pin on an ImageView Android?
body: <p>I would like to ask on how to implement or add a marker on an imageView.
  I rendered an SVG using svglib and used a customImageView so that I can zoom and pan around the image.</p>
  
  <p>here is my code on how i used my customImageView </p>
  
  <pre><code>    @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          SVG svg;
          switch (mNum) {
  
          case 1:
              svg = SVGParser.getSVGFromResource(getResources(), R.raw.t1);
              break;
          case 2:
              svg = SVGParser.getSVGFromResource(getResources(), R.raw.t2);
              break;
          case 3:
              svg = SVGParser.getSVGFromResource(getResources(), R.raw.t3);
              break;
          case 4:
              svg = SVGParser.getSVGFromResource(getResources(), R.raw.t4);
              break;
          default:
              svg = SVGParser.getSVGFromResource(getResources(),
                      R.raw.android);
  
          }
  
          View v = inflater.inflate(R.layout.hello_world, container, false);
          View tv = v.findViewById(R.id.text);
          imageView = (GestureImageView) v.findViewById(R.id.imageView1);
          imageView.setStrict(false);
          imageView.setStartingScale(lastScale);
          // if(lastXPosition!=0 &amp;&amp; lastYPosition!=0)
          imageView.setStartingPosition(lastXPosition, lastYPosition);
          // Log.i("tag",
          // "lastXPosition" + lastXPosition);
          // Log.i("tag",
          // "lastYPosition" + lastYPosition);
          // Log.i("tag",
          // "lastScale" + lastScale);
          // imageView.setRotation(45);
          // imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
          if (Build.VERSION.SDK_INT &gt; 15)
              imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
          imageView.setImageDrawable(svg.createPictureDrawable());
          ((TextView) tv).setText("Floor number: " + mNum);
          imageView.setBackgroundColor(Color.WHITE);
          // tv.setBackgroundDrawable(getResources().getDrawable(
          // android.R.drawable.gallery_thumb));
          // imageView.setScaleType(ScaleType.CENTER);
          // ((GestureImageView)imageView).setScale(x);
          return v;
      }
  </code></pre>
  
  <p>Now I would like to add a pin just like the image below...</p>
  
  <p><a href="https://i.stack.imgur.com/ocg1R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ocg1R.png" alt="My problem"></a><br>
  <sub>(source: <a href="http://www.modality.com/images/appimages/130/screens/645/large.png" rel="nofollow noreferrer">modality.com</a>)</sub>  </p>
  
  <p>But my problem is that when I pan around the marker I added is not bonded with the image SVG thus left behind at a certain position when panning...</p>
  
  <p>Here's my code...
  NOTE: Not yet final... I'm still looking for a way to get this working and I am using a zoomed in imageview as a map... </p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
  
      if (layout) {
          if (drawable != null &amp;&amp; !isRecycled()) {
              canvas.save();
  
              float adjustedScale = scale * scaleAdjust;
  
              canvas.translate(x, y);
  
              if (rotation != 0.0f) {
                  canvas.rotate(rotation);
              }
  
              if (adjustedScale != 1.0f) {
                  canvas.scale(adjustedScale, adjustedScale);
              }
  
              drawable.draw(canvas);
  
              canvas.restore();
          }
  
          if (drawLock.availablePermits() &lt;= 0) {
              drawLock.release();
          }
      }
  
      // ---add the marker---
      Bitmap marker = BitmapFactory.decodeResource(getResources(),
              R.drawable.search_marker_icon);
      canvas.drawBitmap(marker, 40, 40, null);
      Paint mPaint = new Paint();
      mPaint.setColor(Color.RED);
      canvas.drawCircle(60, 60, 5, mPaint);
      super.onDraw(canvas);
  } 
  </code></pre>
  
  <p>Thanks.... I'm new to android  :) hope you can help me....</p>
  
  <p><img src="https://lh6.googleusercontent.com/-Y0dmHnArbPs/ULxYb1YSP3I/AAAAAAAAAQ4/YHsU98qOs30/s640/device-2012-12-03-154223.png" alt="My problem"></p>