开发者

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

Can you please tell me how can I use android's icon expander_ic_maximized? I find that in frameworks/base/core/res/res/d开发者_如何学Crawable-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').


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.


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


Maybe just download and include it in your project

get it from expander_ic_maximized.9.png by clicking the View raw file link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜