开发者

Rotating android view without affecting adjacent views

I'm rotating a view containing an arrow in my app using the Matrix class. However, the arrow doesn't rotate around its c开发者_开发技巧enter but moves a bit horizontally and vertically when rotating. I've experimented with margins and padding but without success. Any hints much appreciated.


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.


I think the translation works as you expect. It is the way you draw the resulting image which leads to imprecision. I have just answered a similar question Android problem with Image Rotate and Matrix

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜