Imageview single and double tap in android? -
i have imageview in android , need show popup while single tap on image , need zoom image while 2 finger cross.
i tried bellow code. can please 1 me.
thanks.
image = (imageview) findviewbyid(r.id.image); gesturedetector gdt = new gesturedetector(new gesturelistener()); image.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(final view view, final motionevent event) { gdt.ontouchevent(event); return true; } }); private static final int swipe_min_distance = 120; private static final int swipe_threshold_velocity = 200; private class gesturelistener extends gesturedetector.simpleongesturelistener { @override public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) { if(e1.getx() - e2.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) { return false; // right left } else if (e2.getx() - e1.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) { return false; // left right } if(e1.gety() - e2.gety() > swipe_min_distance && math.abs(velocityy) > swipe_threshold_velocity) { return false; // bottom top } else if (e2.gety() - e1.gety() > swipe_min_distance && math.abs(velocityy) > swipe_threshold_velocity) { return false; // top bottom } return false; } }
would mind using library chris banes himself, zooming imageview?
Comments
Post a Comment