Skip to content Skip to sidebar Skip to footer

How To Rotate Imageview From Its Centre Position

i want to move my Imageview from its center position. that one side of imageviewgoes above and after this the other side of imageview should comes down centre of imageviewalways f

Solution 1:

use this code

RotateAnimationanim=newRotateAnimation(0, 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

anim.setInterpolator(newLinearInterpolator());
anim.setDuration(500);
anim.setFillEnabled(true);
anim.setFillAfter(true);

image.startAnimation(anim)

Solution 2:

RotateAnimationanim=newRotateAnimation(0, 360, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

anim.setInterpolator(newLinearInterpolator());
anim.setDuration(500);
anim.setFillEnabled(true);
anim.setFillAfter(true);

image.startAnimation(anim);

Solution 3:

Try this..
You can save thisas xml file(image.xml) in res/drawable folder and where you want to rotate imageview then include this line android:src=@drawble/image.

<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%"
android:pivotY="50%" 
android:fromDegrees="0"
android:toDegrees="360" 
android:drawable="@drawable/prgbar" />

Solution 4:

1- One must check width and height of the imageview, if Height > width then at the time of rotation width must be equal to height and same with height.

2- Make width and height equal to fill_parent and then rotate/translate/scale via matrix.

Post a Comment for "How To Rotate Imageview From Its Centre Position"