These two terms occur in many places but what exactly do they mean in the context of Android animations?
Asked
Active
Viewed 3.5k times
48
-
12This question is relevant to Android animations and should not be marked as *closed* / off-topic. – Adam Hurwitz Feb 20 '18 at 21:12
1 Answers
63
The pivotX and pivotY is the central point of the animation.
So for example if you want to do Zoom In animation you can use this
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3" >
</scale>
</set>
and the android:pivotX="50%"
and android:pivotY="50%"
will mean the zoom will be started from the center.
There is also a nice tutorial by android hive here
![](../../users/profiles/1509106.webp)
Niko Adrianus Yuwono
- 10,592
- 7
- 37
- 61
-
1Thanks i was scratching my head for a long time and couldn't get any solutions from google – srujan maddula Oct 23 '14 at 07:58
-
@nayoso for zoom out ?? i am trying to do zoomout then after 1sec it should return back to its position how will i set return back to its position ? ? – Erum May 21 '15 at 13:04
-
3
-
can i change the `android:pivotY="50%"` or `android:pivotX="50%"` value in java ? – medo Jul 22 '16 at 10:08
-
@medo I don't think you can modify it but you can create an animation with your desired pivot with ScaleAnimation constructor. – Niko Adrianus Yuwono Jul 25 '16 at 02:10
-