Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: custom shaped button

Tags:

android

button

I'm looking the best way to create a group of four buttons.
enter image description here
Each button is an image. So, I think about just create a "big" square from four small images-buttons and then rotate them.
The question is: how to rotate layout in xml? Is it possible?

Is there any better way to create such group of buttons?


Thank you!

like image 572
Dmitry Avatar asked Jun 06 '11 15:06

Dmitry


2 Answers

One way to do this is to create a single ImageButton, then use trigonometry to work out where the user has clicked on the circle, using data from an onClick() event and the centre of the button. This question may help: Get the co-ordinates of a touch event on Android

like image 176
Glitch Avatar answered Oct 10 '22 09:10

Glitch


The ultimate answer is to use a pathshape button. Then it handles everything for you.

Create the paths with Path the shapes with Shape and the composite pathshape with Pathshape.

That way you can do it even in XML. And there's a variety of arc path methods. Check it out!

like image 23
David at HotspotOffice Avatar answered Oct 10 '22 09:10

David at HotspotOffice