As far as I know for now (which is little), all the Views in Android have square or rectangular shapes. This is fine almost all the time until you want – what I actually want – to create non-square shapes that could handle events.
My goal is to have a circle divided in 3 sections of 120° each. Each section of the circle should behave like a button. The problem is that if we look at those 3rds of a circle and place them in a square box that strictly contains them, they are overlapping each other: not practical to know which the user meant to click…
I tried with a custom view in which I drew my sections but the events are triggering on all the surface of the view.
Any suggestion or direction is very welcome.
Thx, Paul
First thank you a lot for all your suggestions which helped me to reach the goal.
Since there is no way to trigger events on shapes, using onTouch() on the view which contains the shapes is the way to go.
Following, all you need to run it.
First, the custom view Zones.java:
Second, the main activity, Design.java:
… and the main xml view (which embeds our custom class view) main.xml
Any comments appreciated!
Paul 🙂