Where are all the standard Android icon resources?
I have just started writing my first ever Java/Android application, so forgive the total n00b question.
How do you access the the standard operating system icons such as search icon/menu icon etc? They are not in the res/drawable folder where I would expect to find them. Are they available as part of the SDK or must you download them seperately?开发者_C百科
EDIT
Maybe you can help me further - I am getting the following error (repeated on):
[2011-09-08 19:59:47 - TweetTab] C:\Users\Dan\workspace\TweetTab\res\menu\options_menu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_search').
However, the icon is not empty, the xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/search"
android:icon="@drawable/ic_menu_search"
android:title="@string/search"/>
</menu>
Am I missing something?
SOLVED
I changed android:icon="@drawable/ic_menu_search"
to android:icon="@android:drawable/ic_menu_search"
and it could then find the icon.
You can acces them via android.R.drawable.*
or in xml by @android:drawable/something
.
I installed the Android SDK for Eclipse on Windows.
Now I can find all ressources under "C:\Program Files\Android\android-sdk-windows\platforms\android-9\data\res..."
try this instead:
android:src="@android:drawable/ic_menu_camera"
it is now possible to use vector assets to generate standard (or customised) icons for android.
- Add 'com.android.tools.build:gradle:1.4.0-beta3' to your build.gradle file. (The stable version will be out in the coming weeks).
- Add a vector asset by right-clicking res/drawable/ > New > Vector Asset. Android Studio provides a built-in viewer for you to pick your drawable.
- Reference your icon like you usually do. Eg: android:icon="@drawable/ic_help_24dp"
A lot of them can be found in android.R.drawable
but not all are publicly accessible
You can find the android.R.drawable images in your local SDK folder. (Tested using Android Studio 3.0)
First have a look at the docs for the names of the drawables here: https://developer.android.com/reference/android/R.drawable.html
Second either search your drive for one of those image names.png or type in the name of any of them into your Android Studio activity and right click (goto declaration) on it to view the image. Then you can also right click that image to copy the path. Then open that folder and look at all the PNG's there.
Example on windows 10: android.R.drawable.star_big_on is located in user/AppData/Local/Android/Sdk/platforms/android-25/data/res/drawable-hdpi/star_big_on.png
(Note also on windows AppData is a hidden folder so you may need to set your windows explorer to show hidden if you are clicking to open each folder)
Also if you need to see material design icons / descriptions this is a good place to look: https://material.io/icons
Someone may see this page useful for getting those icons... http://developer.android.com/design/style/iconography.html
For those of you in the Visual Studio/Xamarin Android camp, you can view and add the standard Material icons pretty easily using the following plugin:
https://marketplace.visualstudio.com/items?itemName=nikainteristi.Materialiconsgenerator
I've used it a few times in my projects.
精彩评论