I have an ImageView and Button. Button view positioned at bottom of the screen. ImageView positioned above of the button. When i click the button, image should move to center of the screen. After moving to center, click on image should spin. But in my case it spin in wider circle instead of the spin at center.
I am using below code.
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:scaleType="centerCrop"
android:visibility="visible" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Start" />
after click on button, moving to center of the screen
image.animate().y(metrics.heightPixels / 2 - image.getHeight() / 2).x(metrics.widthPixels / 2 - image.getWidth() / 2)
Rotating the image after above step.
RotateAnimation animRotate = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animRotate.setDuration(duration);
animRotate.setInterpolator(new DecelerateInterpolator(1.5f));
image.startAnimation(animRotate)
Instead of spinning at the center, it spin like wider circle. Can you help.
