What I need to achieve here is as following 1) superimpose a transperent "dot" on the PNG image ; where user has clicked. 2) superimpose a transperent "Big circle", when user is holding touch for long. 3) upon Doble click "Clear the screen"
Primarily I am using "onTouchEvent" for click-event detection... and "geastureDetector" for doubleTap detection... but not getting the desired result.
These are the 2 implementations I am trying out
This first approach works fine ... But the click event generated is with some deviation... I mean to say the click event captured is always Offset by around 50 pixels in Y direction.... I am not able to figure out why this should happen..
class Tileview extends Activity implements GestureDetector.OnGestureListener,GestureDetector.OnDoubleTapListener {
onCreate(){
//add the View Thing here.
}
@Override
public void onLongPress(MotionEvent e) {
// "longPress Detected"
}
@Override
public boolean onDoubleTap(MotionEvent e) {
// "longPress Detected"
}
@Override
public boolean onTouchEvent(MotionEvent event) {
final int action = event.getActionMasked();
switch(action){
case MotionEvent.ACTION_DOWN:
mClickX = event.getX();
mClickY = event.getY();
}
myTileView.invalidate();
return mGestureDetector.onTouchEvent(event);
}
private class MyTileView extends View{
protected void onDraw(Canvas canvas){
// Canvas & Paint stuff - for translucent cicle
c.drawCircle(mClickX, mClickY, 75.0f, p);
}
}
The other approach is able to superimpose the image propely at proper location; but when I add the DoubleTap implementation in the "View" instead of Activity .. the doubleTap / geastureListeners would never fire .... Only change I did in that case was to get the onTouchEvent() - and corrsponding implementation in "view" class....
class TileActivity extends Activity {
OnCreate()
{
// Bla Bla Bla
}
private class TileView extends View implements OnDoubleTapListener, OnGestureListener{
@override
onTouchEvent(){
// get co-ordinates here from MotionEvent
}
@Override
public boolean onDoubleTap(MotionEvent e) {
// THIS WON'T EVEN GET FIRED
// In this case the doubleTap detection is not working
clearEntireScreen = true;
return false;
}
}
}