I want to use a series of RotateDrawable objects to animate a compound pendulum (so the pivot point of a second RotateDrawable must be “attached” to a point on a first RotateDrawable). This means I need to calculate where a point in the drawable is after a rotation has taken place. There don’t seem to be methods for getting or setting the pivot of a RotateDrawable; short of retrieving them directly from XML when the thing is inflated I can’t think of a way to do this.
I want to use a series of RotateDrawable objects to animate a compound pendulum
Share
Getting the pivot from XML during inflation can be done in a manner similar to:
The attribute SHOULD be between zero and one (if present) and 0.5f is the default value set by Android if the attribute is absent.
http://idunnolol.com/android/drawables.html#rotate
IMPORTANT NOTE
I’ve realized it’s also important to get
android:fromDegreesandandroid:toDegreesas if, like me, you’re usingonLevelChanged(int)to get the quantity of rotation, you need to know how much rotation you are actually getting. The same method works for these attributes. The defaults are 0.0f and 360.0f (in degrees). Level is between 0 and 10,000, with 0 corresponding tofromDegreesand 10,000 corresponding totoDegrees.