I'm new, so links and images are here
Hi,
I'm likely making a silly mistake... hoping to find out what that is.
I'd like to use a few of the standard menu icons (ic_menu_refresh, etc.) in my app's Options Menu. And I'd like to set the icons in the xml file for the menu. I read in a few places that I can use the following:
<item android:id="@+id/quit"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="Quit" />
to make a quit button in my menu. And this works nicely. However, I'd also like to use some other icons, like ic_menu_stop.png, which are apparently "not public" [link1]. Also, I've read in a few places that it's not a great idea to "reference internal graphics like that" [link2]. Likewise, I don't want to use the asterisk workaround [link3] to allow access to private resources. The solution offered is to make a local copy of the drawables.
So I copied the image files I wanted from C:\...\android-8\data\res\drawable-hdpi
into my project's res\drawable
folder, and then changed the above xml to:
<item android:id="@+id/quit"
android:icon="@drawable/ic_menu_close_clear_cancel"
android:title="Quit" />
However, this causes the icon to stretch (I believe the icon is stretched - and not simply a bigger (hdpi) image file - because it's slightly blurred) and either obscure or crowd out the title text, so all I see is the oversized, blurry icon. Of course, I also tried copying the icon from the drawable-mdpi
folder: using the mdpi icon doesn't obscure the title, but the icon is slighlty undersized and blurry.
I wanted a screenshot, so I switched to running the app on my emulator. However, the blurring isn't apparent, and the local mdpi image seems to match the internal one I'm referencing:
[screenshot] (follow the link at the top!)
I have double-checked :), and it really is blurred on my phone (Motorola Droid).
It also occurred to me that the referenced one might be getting the icon via an xml file (like a state-list drawable), and that the xml file somehow defined how the image was to be drawn. I tried making one with a bitmap element, and tried setting a couple of the properties in ways I thought might help:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_menu_close_clear_cancel"
android:gravity="top"
android:filter="false" />
It worked to display the icon (I was proud of myself), but didn't affect the stretching issue.
I also found these [link4 and link5] pages, but they seemed to have different issues.
Perhaps I should be copying the icons from another location? Am I on the right track with the xml file? Help?
Thanks,
Nolan