Skip to content Skip to sidebar Skip to footer

Get Touch Coordinates Relative To A Custom Imageview

I implemented custom ImageView. Because my image is large I'm using ScrollView and HorizontalScrollView to scrolling image. I want to draw circle in onTouch event, but its not work

Solution 1:

I found solution. Just replace

float viewX = e.RawX - this.Left;
                    float viewY = e.RawY - this.Top;
                    point.x = viewX;// e.RawX;
                    point.y = viewY;// e.RawY;

with

float viewX = e.RawX;// - this.Left;float viewY = e.RawY;// - this.Top;int[] viewCoords = newint[2];
                        this.GetLocationOnScreen(viewCoords);
                        point.x = viewX - viewCoords[0];// e.RawX;
                        point.y = viewY - viewCoords[1];// e.RawY;

Post a Comment for "Get Touch Coordinates Relative To A Custom Imageview"