0

I'm trying to get the actual touch pixel of a background image of an android studio xml. I'm trying to start a new activity when touch position is in bounds of desired coordinates. Thank you!

1

1 Answer 1

3

you can set onTouchListener() on your layout with background image.

RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main_layout); mainLayout.setOnTouchListener(this); // in this case activity should implements View.OnTouchListener 

Then use something like that

public boolean onTouch(View v, MotionEvent event) { Point touchPlace = new Point(); touchPlace.set(event.getX(), event.getY()); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.