Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use a system provided icon in Android (e.g. expander_ic_maximized)

Tags:

android

Can you please tell me how can I use android's icon expander_ic_maximized? I find that in frameworks/base/core/res/res/drawable-hdpi/expanderic_minimized.9.png

Here is my layout xml file:

<ImageView android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/expander_ic_minimized">

But I get this error:

res/layout/test.xml:70: error: Error: Resource is not public. (at 'src' with value '@android:drawable/expander_ic_maximized').
like image 495
michael Avatar asked Jul 13 '10 16:07

michael


2 Answers

You can find all android icons in your android SDK installation directory. F.ex. /opt/android-sdk-linux/platforms/android-16/data/res/drawable-hdpi/ on my computer. There are different sets of icons for different android versions and for different screen resolutions. Copy expander_ic_minimized.png files to your project drawable folders and the icon will become available.

According to android developer guide:

Because these resources can change between platform versions, you should not reference these icons using the Android platform resource IDs (i.e. menu icons under android.R.drawable). If you want to use any icons or other internal drawable resources, you should store a local copy of those icons or drawables in your application resources, then reference the local copy from your application code. In that way, you can maintain control over the appearance of your icons, even if the system's copy changes.

like image 139
bancer Avatar answered Sep 19 '22 14:09

bancer


According to this thread, you will have to manually copy that icon into your project and use it from there.

like image 24
Cristian Avatar answered Sep 19 '22 14:09

Cristian