animation - Android-Rotate and Expand imageview -
im trying rotate imageview in degrees , @ same time expand imageview's height ! code far :
public class tonguehandler { imageview tongue; relativelayout.layoutparams tongue_params; objectanimator rotate_tongue; scaleanimation scale_tongue; animationset as; imageview frog; button btn; public tonguehandler(button btn,imageview frog,imageview tongue){ this.btn=btn; this.frog=frog; this.tongue=tongue; } public void initialize() { tongue.setbackgroundcolor(color.red); tongue_params=new relativelayout.layoutparams(10,100); tongue_params.leftmargin=frog.getleft()+frog.getwidth()/2; tongue_params.topmargin=frog.gettop()+frog.getheight()/2; tongue.setlayoutparams(tongue_params); animate(); } public void animate() { as=new animationset(true); rotate_tongue=objectanimator.offloat(tongue, "rotationx", 90.0f, 90+calcangle(frog,btn)); rotate_tongue.setduration(1); rotate_tongue.start(); system.out.println("this angle: "+calcangle(frog,btn)); /* scale_tongue=new scaleanimation(1,1,30,btn.gety(),1,2); scale_tongue.setduration(500); */ // as.addanimation(scale_tongue); tongue.startanimation(as); as.setanimationlistener(new animation.animationlistener() { @override public void onanimationstart(animation animation) { } @override public void onanimationend(animation animation) { /* as=new animationset(false); rotate_tongue=new rotateanimation(0,calcangle(frog,btn),frog.getwidth()/2,frog.getheight()/2); rotate_tongue.setduration(1); scale_tongue=new scaleanimation(30,btn.gety(),2,2,15,0); scale_tongue.setduration(200); as.addanimation(rotate_tongue); as.addanimation(scale_tongue); tongue.startanimation(as);*/ } @override public void onanimationrepeat(animation animation) { } }); } public float calcangle(view frog,view fly) { float angle = (float) math.todegrees(math.atan2(frog.gety() - database.flyy, frog.getx() - database.flyx)); if(angle < 0){ angle += 360; } /* if (frog.getx()>=database.flyx) { angle=-90f-angle; } else { angle=-90f+angle; }*/ return angle; } }
the problem doesnt work @ image rotates in wrong degrees (also instantly not 1ms delay) , result not sutisfying appreciated thank ;)
Comments
Post a Comment