I would like to add a favorites star like the one in the contacts list on android. Is there any way we can get that star or will I have to write my own? I can\'t seem to find
@android:drawable/btn_star (this one turns yellow)
@android:drawable/star_off
and variations on those (big, on, off)
Some standard android images are available from the android sdk, which you can either browse on your computer on online here. (As CommonsWare said).
I also find this website super handy, as it shows me what each image looks like and tells me the name of the image so I can find it in the android sdk.
The source code to the Contacts application is available online, since Android is open source.
Some poking around in there will lead you to the contact_header.xml
file, found in your SDK installation. It indicates that the star is implemented via a CheckBox
:
<CheckBox
android:id="@+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:visibility="gone"
android:contentDescription="@string/description_star"
style="?android:attr/starStyle" />
That, in turn, routes you to an entry in a theme:
<item name="starStyle">@android:style/Widget.CompoundButton.Star</item>
which in turn resolves to:
<style name="Widget.CompoundButton.Star">
<item name="android:background">@android:drawable/btn_star_label_background</item>
<item name="android:button">@android:drawable/btn_star</item>
</style>
So, use those images with a CheckBox
, and you should get the same behavior. Those images are also available in your SDK installation.