Android: How to change the default shape of a button?
Is it possible to change the default shape (i.e rectangular) of the button (normal 开发者_JAVA技巧button as well as imagebutton) to something else maybe like star or a triangle in Android? Any tutorials or sample code would be much appreciated.
That depends on how you define "shape".
Visually, you change the shape by changing the button background resource. See this previous SO question and answer.
However, I haven't tried this with something non-rectangular, so it is possible that while it will look like a star, the "hot zone" for clicks might still be the original rectangle.
You might look at the implementation of RatingBar
in the Android open source code, which uses stars, and see if they do anything unusual.
精彩评论