0

I am kind of new to the onDraw so i don't know how to go around this problem.

I want to draw a image at this location (just so i can try the rest myself). These locations are off the ontap and * the drawables width and height. This code is in a class that extends photoview.

The problem is this resource is not being displayed, i also tried to use on a drawcirlce example that also didnt display. I have also attached that below.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    Bitmap markerBitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.markerformap);
    canvas.drawBitmap(markerBitmap, 2000, 5000, new Paint());
}

Draw circle example

    canvas.drawCircle(2000, 5000,300, new Paint());

The onTouch Listener

    @Override
    public boolean onTouch(View v, MotionEvent event) {
            if(y != event.getY() && x != event.getX()){
                    x = event.getX();
                    y = event.getY();
                    return true;
            }
            return false;
    }
Darren
  • 75
  • 6
  • change `2000, 5000` - > `0, 0` and check again – pskink Jan 03 '18 at 18:06
  • @pskink it loads fine in the top right, i dont know how to solve the problem though – Darren Jan 04 '18 at 00:05
  • so what is your problem actually? why you use `2000, 5000` ? what do you really want to achieve? – pskink Jan 04 '18 at 08:05
  • @pskink want the ontap to display a image on top of where the person tapped. The numbers were the ontap x* width of bitmap and y* height of bitmap. The numbers were there just to see if it would even display. – Darren Jan 04 '18 at 17:46
  • so if you use `0, 0` it displays, now what? instead of `2000, 5000` use `event.getX()` and `event.getY()` – pskink Jan 04 '18 at 17:47
  • i am using onPhotoTap which doesn't recognize that method. Should i not use the floats given in that method? – Darren Jan 04 '18 at 17:59
  • it does not have `onTouchEvent` ? – pskink Jan 04 '18 at 18:02
  • No, i am using this one https://github.com/chrisbanes/PhotoView/blob/master/photoview/src/main/java/com/github/chrisbanes/photoview/OnPhotoTapListener.java. – Darren Jan 04 '18 at 18:04
  • just override `onTouchEvent` and store the event position somewhere – pskink Jan 04 '18 at 18:06
  • @pskink I have added my ontouch to the code in the main question. I have also stored them and its called in a if statemet to see if it was the same as previous and if so doesn't create a new one. Shamefully is still doesnt work and it is called in the constructor. – Darren Jan 04 '18 at 18:23

0 Answers0