android - Rotation animation is not spinning the asset in center point -
i'm trying rotate round button when pressed.my problem button doesn't rotate around it's own centre. followed other examples outcome same. here code:
rotate.xml:
?xml version="1.0" encoding="utf-8"?>
<rotate android:duration="1500" android:interpolator="@android:anim/linear_interpolator" android:pivotx="50%" android:pivoty="50%" android:repeatcount="infinite" android:repeatmode="restart" android:todegrees="360" />
and in class i'm using animation:
animation animrotate = animationutils.loadanimation(getcontext(), r.animator.rotate); @override public boolean ontouchevent(motionevent event) { log.e(tag, "event:::" + event.getaction()); if (event.getaction() == motionevent.action_down) { view.startanimation(animrotate); view.setbackgroundresource(r.drawable.some_asset); } else if (event.getaction() == motionevent.action_up ) { view.clearanimation(); view.setbackgroundresource(r.drawable.some_asset); }
thank you!
a simple way rotate view
matrix matrix = new matrix(); view.setscaletype(scaletype.matrix); //required matrix.postrotate((float) angle, pivx, pivy); view.setimagematrix(matrix);
Comments
Post a Comment