开发者

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

开发者 https://www.devze.com 2022-12-30 14:41 出处:网络
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 tutoria

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消