android - Simultaneously scale and translate ImageView based on Target -


what want simultaneously scale , translate imageview based when user touches is. final position , size of imageview should equal target.

below snipper of onclicklistener attached every imageview should perform action. new position , size obtained ivyou, imageview.

@override     public void onclick(view v) {         // create animations         int[] = new int[2];         int[] = new int[2];         //v.getlocationinwindow(from);         v.getlocationonscreen(from);         //ivyou.getlocationinwindow(to);         ivyou.getlocationonscreen(to);         translateanimation transanim = new translateanimation(0, to[0] - from[0], 0, to[1] - from[0]);          float factorx = ivyou.getwidth() / v.getwidth();         float factory = ivyou.getheight() / v.getheight();         scaleanimation scaleanim = new scaleanimation(1.0f, factorx, 1.0f, factory);          // create animation set         animationset set = new animationset(true);         set.setfillafter(true);         set.setduration(anim_duration);         set.addanimation(transanim);         set.addanimation(scaleanim);          // start animations , disable click listener         v.startanimation(set);         v.setonclicklistener(null);     } 

anim_duration 2000 miliseconds.

when run code strangest things happen. imageview turns half circle , gets smaller supposed be. when not add scaleanimator animation set, imageview moved new position. however, new position isn't same every imageview. note imageview's onclicklistener have different initial position.

any , feedback appreciated!

i able achieve animation wrapping target view in layout group , animating them separately.

in other words, translate wrapper layout, , scale child view. translating , scaling same view @ same time seems result in unexpected animation trajectories scaling messes coordinate system translate animation using.

translatetarget.animate().x(deltax).y(deltay).setduration(1000); scaletarget.animate().scalex(0.01f).scaley(0.01f).setduration(1000) 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -