Reputation: 12587
is there a way to force a button using system resources such as @android:drawable/ic_menu_send
be with the background I choose?
the default is this:
and the desired one for me is this:
Upvotes: 1
Views: 854
Reputation: 527
I would recommend to use the desired icon from the "Action Bar Icon Pack" provided by Google referenced on http://developer.android.com/design/style/iconography.html#action-bar
There you will find the icon 6_social_send_now.png
for holo_light
and holo_dark
theme.
One reason to not reference system icons directly from the SDK is given in "The Busy Coder's Guide to Android" by Mark L. Murphy: "However, there is a risk: device manufacturers are welcome to replace these drawables with their own artwork." and those might not fit to the other (selfmade) icons in your app.
Upvotes: 2
Reputation: 4236
Did you try style attributes starting with "?":
?android:drawable/ic_menu_send
Update:
As it seems it is not that easy. First you have to check for which drawables
there is an entry in the SDK resources, e.g. look in folder android-sdk/platforms/android-15/data/res
of your Android SDK installation. There you can grep
for your drawable
.
In the following example we find that there is no entry for ic_menu_send
in themes.xml
(only in public.xml
) and therefore no entry for the corresponding attribute in attrs.xml
.
A drawable which would work is ic_menu_share
where we can find entries in themes.xml
and attrs.xml
so we can use the style attribute in the following way android:src="?android:actionModeShareDrawable"
jh@jh-aspire:/opt/android-sdk/platforms/android-15/data/res$ grep -r ic_menu_send *
values/public.xml: <public type="drawable" name="ic_menu_send" id="0x01080050" />
jh@jh-aspire:/opt/android-sdk/platforms/android-15/data/res$ grep -r ic_menu_share *
values/public.xml: <public type="drawable" name="ic_menu_share" id="0x01080052" />
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_dark</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_light</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_dark</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_light</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_dark</item>
jh@jh-aspire:/opt/android-sdk/platforms/android-15/data/res$ grep -r actionModeShareDrawable *
menu/webview_copy.xml: android:icon="?android:attr/actionModeShareDrawable"
values/attrs.xml: <attr name="actionModeShareDrawable" format="reference" />
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_dark</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_light</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_dark</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_light</item>
values/themes.xml: <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_dark</item>
Upvotes: 0