I'm trying to figure out a way to layout a series of views around a circle, in such a way that each view is rotated to be facing outward from the circle. The picture below is a rough sketch of what I'm looking for. The outside block is the layout/viewgroup, the red squares represent the views I want to rotate.
I'm familiar with the PivotX, PivotY, and Rotation view properties and suspect I will be making use of these in some way, but I'm not sure how to use these in concert with an appropriate layout to get the desired effect.
The answer by @Daniel is great.
If you need more functionality you can use this nice library on GitHub called Android-CircleMenu
Here's an example that does this. I created a new Android project and replaced the
RelativeLayout
that's already there, with aFrameLayout
. It's >= API 11 only because of translate and rotate calls inView
:I'll create some quick views in code, just replace them with whatever views you have. I'm placing them all in the center of the layout, by setting the gravity of their
LayoutParams
toGravity.CENTER
. Then, I'm translating and rotating them to their correct positions:And this is the result: