What I'm aiming to do is to allow the user of my Android application to select points on the face and retrieve the X and Y coordinates from that touch. Please see the below picture.
I would like the user to be able to change the size of the selection square.
So far I have the below code, but I honestly have no idea where to go from there. How do I go about drawing a rectangle that the user can manipulate and move (and then return the X and Y centerpoint coordinates from that)? I'm sure there's an Android feature for this.
private void selectImg(){
//retrieve X and Y values from touch
surfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent pos) {
//retrieve position when user finishes touch
if (pos.getAction() == MotionEvent.ACTION_UP){
Log.d("X",String.valueOf(pos.getX()));
Log.d("Y",String.valueOf(pos.getY()));
}
return true;
}
});
}
Thank you!
Could be useful: Custom Android Image Crop https://github.com/dtitov/pickncrop/blob/master/src/com/github/pickncrop/MainActivity.java