Wednesday, September 28, 2011

Android Favorite Button

I love Android. What I hate about it, though, is that they don't tell you how to make standard-looking UIs. For example, I had to dig through source codes to find the @android:style/ButtonBar style that you can use as the style on pretty much any layout (RelativeLayout, LinearLayout, etc.) which provides a nice background graphic for your button bars. Anyway, today I discovered another such hidden feature – a star drawable that can be used for favorite buttons. However, I still don't understand a thing: there's btn_star, btn_star_big_off and btn_star_big_on. One would think "how do I get btn_star_on then?", but then one would realize btn_star and btn_star_big_* are the same size (all of these are in @android:drawable/). In short, to create a favorite button/image, use:
<ImageView android:src="@android:drawable/btn_star_big_off"/> <!-- or, if you want the button-like background and borders (although I prefer the ImageView version) --> <ImageButton android:src="@android:drawable/btn_star_big_on"/>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.