android - Is it possible to set animation pivot value based on touch event? -
i have imageview, , have scaleanimation.
scaleanimation scaleanimation = new scaleanimation(1.0f, 5f, 1.0f, 5f, scaleanimation.relative_to_self, 0.5f, scaleanimation.relative_to_self, 0.30f); scaleanimation.setduration(9000); imageview lol = (imageview) findviewbyid(r.id.imageview1); lol.setimageresource(r.drawable.img1); lol.setanimation(scaleanimation);
works great , everything, user able decide part of image gets zoomed in on. there way convert touch coordinates pivot value?
thanks!
like alanv suggesting, can utilize ontouchlistener
on imageview
touch cordinates , pass values scale animation. this:
lol.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(final view v, motionevent event) { scaleanimation scaleanim = scaleanimation; log.i(tag, "x:"+event.getx() + ", y:"+ event.gety()); startscaleanimation(v, scaleanim, event.getx()/v.getwidth(), event.gety()/v.getheight()); v.performclick(); homecoming true; } }); //a method execute animation static void startscaleanimation(view v, scaleanimation scaleanim, float pivotx, float pivoty){ scaleanim = new scaleanimation(1.0f, 5f, 1.0f, 5f, scaleanimation.relative_to_self, pivotx, scaleanimation.relative_to_self, pivoty); scaleanim.setduration(4000); v.startanimation(scaleanim); }
this scale imageview
point user touched.
android animation imageview zoom scaleanimation
No comments:
Post a Comment