Android: How to change the default shape of a button?

Is it possible to change the default shape (like a rectangular) of a button (a regular button as well as an image button) to something else like a star or triangle in Android? Any tutorials or code examples would be much appreciated.

+2


a source to share


1 answer


It depends on how you define "shape".

Visually, you change the shape by changing the background resource of the button. See this previous SO question and answer .



However, I haven't tried this with anything non-rectangular, so it is entirely possible that although it looks like a star, the "hot zone" for clicks may still be the original rectangle.

You can take a look at the RatingBar

open source Android implementation that uses stars and see if they do something out of the ordinary.

+4


a source







All Articles