I am trying to create a view where the icons are placed in the circular view rather then the existing view like grid or the gallery view. I tried with Carousel example but later on found that it will not meet my requirement because its 3D app, but i am looking for 2D View.Android 3D Carousel
This is the example that I was following. I was able to get the circular kind of thing but to meet my requirement I should stick with 2D.
My one more major requirement is inside circular view I must also have another circular view, something like below figure
Can anyone help me out in this?
You can use <clip /> drawable in order to cut-off part of your circle.
For the layout of each circle I suggest this answer to question layout with buttons in a circle because it defines your item positions relative to the center of the enclosing RelativeLayout regardless of its size. You can then overlay the two circle layouts thus:
<RelativeLayout ...>
<RelativeLayout // outer circle
android:layout_alignParentCenter>
...
</RelativeLayout>
<RelativeLayout // inner circle
android:layout_alignParentCenter>
...
</RelativeLayout>
</RelativeLayout>
To rotate each of the circles independently, I suggest following this answer to question **Rotate View Hierarchy 90 Degrees".
If you are not looking for an animated circular view, you can use Absolute Layout, and position them in code using an algorithm to check if the various (x, y) positions fall on a circle's circumference.
Assuming you want the circular view centered at (x,y)
and radius r
to have n
items, then the co-ordinates would be:
(x + r, y) // for the first element
....
(x + (r * (FloatMath.cos((p-1) * 2 * Math.PI / n))), y - (r * (FloatMath.sin((p-1) * 2 * Math.PI / n)))) // for the 'p'th element
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With