<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/your_drawable"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
I want programmatically rotate the drawable.
How should I do that?
Here is my callback
private class RotateListener implements RotateGestureDetector.OnRotateGestureListener{
@Override
public boolean onRotate(MotionEvent event1, MotionEvent event2,
double deltaAngle) {
return true;
}
}
The deltaangle
not more than 0.1, I not sure what is the extract value.
here's a nice solution for putting a rotated drawable for an imageView:
usage:
another alternative:
also, if you wish to rotate the bitmap, but afraid of OOM, you can use an NDK solution i've made here
Since you're trying to use Almero's Android Gesture Detectors, I decided to do the same in order to find an appropriate solution:
It works fine for me (I'm able to rotate the ImageView with two-finger rotation gesture. NOTE: Don't forget to chose appropriate rotation method call. I commented both of them to draw your attention.
ROTATION_RATIO is just a multiplier to speed-up a rotation response on my fingers movement. You can use any rotation axis (setRotation(), setRotationX() and setRotationY()) methods for a View.
To enable support of this code on Android devices with API Level lower than 11 (pre-Honeycomb devices) you may want to engage NineOldAndroid library.
The following code rotates an ImageView around its center: