Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android setting pivot point for scale animation

Tags:

I am trying to scale views to a certain size but can't quite understand how pivoting works.

Say I want to scale the view upwards only. What value should the "pivotY" hold? In XML, it is a percentage. How is it when applying pivot point programmatically?

Example:

ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", scaleSize); ObjectAnimator pivotY = ObjectAnimator.ofFloat(view, "pivotY", pivotPoint);  AnimatorSet set = new AnimatorSet(); set.PlayTogether(scaleY, pivotY); 
like image 914
TalMihr Avatar asked Jun 10 '13 20:06

TalMihr


2 Answers

Quite simple actually.

If you want to scale upwards one clear option is:

 view.setPivotY(100); 

and downwards:

 view.setPivotY(0); 

then animate.

like image 85
TalMihr Avatar answered Sep 18 '22 22:09

TalMihr


Use:

view.setPivotY(view.getMeasuredHeight()); 

If you need to animate your object from the bottom.

like image 33
DoruChidean Avatar answered Sep 17 '22 22:09

DoruChidean