I have a bitmap and I draw it like this :
bit = BitmapFactory.decodeResource(getResources(),
R.drawable.anim_ctrl_panel);
Paint paint = new Paint();
canvas.drawBitmap(bit, 80, 440, paint);
The problem is that the image is set as fullscreen .On onTouchEvent
method I implement the event for the bitmap and anywhere I select screen the event is implement. I want the image to have a certain position and only for that position to be implement the event. How can I do this?
EDIT: the problem was at onTouchEvent method. This is the solution :
public boolean onTouchEvent(MotionEvent event) {if(80 <= event.getX() && event.getX()<= (80+bit.getWidth()/2) && (440 <= event.getY() && (event.getY() <= 440+bit.getHeight()))){
//...
}else if((80+bit.getWidth()/2) <= event.getX() && event.getX()<= (80+bit.getWidth()) && (440 <= event.getY() && (event.getY() <= 440+bit.getHeight()))){
//...
}
this help me : How can I check the Image is Touched using OnTouch()