1

I am trying to apply two different rotations to a view, let's say for example :
1 : 20° pivotX = width/2 pivotY= height/2
2 : 90° pivotX = 0 pivotY= 0

However View.setPivotX() & View.setPivotY() both seem to only change the values in an unique matrix, so when I change the pivots, it reapply the first rotation with that new pivot, which is not what I want to do.

Is there a way to handle these two rotations in a totally independent way ?

Teovald
  • 4,369
  • 4
  • 26
  • 45
  • Different question, but you might find this helpful with regard to pre, post, set and clear. http://stackoverflow.com/questions/13246415/clearly-understand-matrix-calculation/13246914#13246914 – Simon Apr 09 '13 at 00:15
  • @Simon yes, I think that I will have to do something like this. I can always apply my two rotations from the same pivot and compensate with setTranslationX/Y but I would like to be able to define them separately in order to avoid unnecessary calculations. – Teovald Apr 09 '13 at 12:05

1 Answers1

1

You can use two different methods to set both of your rotations'. first is :

RotateAnimation rotateAnimation = new RotateAnimation(0f, 20f,  width/2, height/2);
rotateAnimation.setDuration(0);
rotateAnimation.setFillAfter(true);
View.setAnimation(rotateAnimation);

and the second one :

View.setPivotX(0);
View.setPivotY(0);
View.animate().rotation(90f).setDuration(0);
Arya Sadeghi
  • 480
  • 2
  • 16