I'm rotating a view containing an arrow in my app using the Matrix class. However, the arrow doesn't rotate around its center but moves a bit horizontally and vertically when rotating. I've experimented with margins and padding but without success. Any hints much appreciated.
+1
A:
The setRotate method in Matrix defaults to the (0,0) point of the view, which is the top left corner. You can set the point you want to rotate around by using the setRotate(float angle, float px, float py) method in the Matrix class. The x and y parameters are local to the view so you can get the center point from the bounds of the view or from getWidth and getHeight.
Frank
2010-08-30 19:59:36
Thanks for the reply. Yes I did try setting the pivot points to the center of the view (x/2,y/2) but without success.
Christian
2010-08-31 08:30:39
Did you try width/2,height/2?
Frank
2010-08-31 18:03:02
Yeah I did. I guess that I have to put my arrow-ImageView in some sort of container box whos side's are longer than the ImageView's diagonal so that the ImageView rotates inside this box without affecting adjacent views.
Christian
2010-09-01 06:19:47