安卓:访问"系统" -drawables系统、QUOT、drawables

2023-09-07 11:52:35 作者:情定剑门关

我目前工作的一个应用程序,以显示电池状态,我想用Android的可绘制的,而不是自己的形象,以减少应用程序的大小。

I'm currently working on an app to display the battery status and I'd like to use Android-drawables instead of own images to reduce the app size.

我发现这个网页,其中列出了可用的图像和可用性每个SDK版本:的 http://www.fixedd.com/projects/android_drawables_display

I've found this page which lists available images and the availability for each SDK-version:http://www.fixedd.com/projects/android_drawables_display

我的问题:我如何才能访问系统-drawables?如果你点击链接并选择选项卡状态,也有一些电池可绘制样stat_sys_battery_0,但我不能访问它,Eclipse不提供智能感知它,如果我不会编译应用程序使用这些可绘制中的一个。

My question: How can I access the "system"-drawables? If you click on the link and choose the tab "Status", there are some battery-drawables like "stat_sys_battery_0", but I can't access it, Eclipse doesn't offer intellisense for it and won't compile the app if I use one of those drawables.

由于这些可绘制都是SDK-版本的一部分,我想我应该能够使用它们,或者是在某种程度上保护那些特殊可绘制,使他们只能通过系统功能(而不是应用程序)?

As those drawables are part of all SDK-versions, I'd think I should be able to use them, or are those "special" drawables protected in a way so they can only be used by system-functions (and not apps)?

任何想法是AP preciated。

Any idea is appreciated.

Select0r

推荐答案

有实际上似乎有一种方法来访问系统图标,但它在文档中表示不是真正的工作,但我会在万一有人添加爱好:

There actually seems to be a way to access the system icons, but it's not really working as stated in the documentation, but I'll add it in case somebody is interested:

intent.getIntExtra(BatteryManager.EXTRA_ICON_SMALL,-1)

将得到匹配当前电池状态的图标,你的资源ID:的http://developer.android.com/reference/android/os/BatteryManager.html#EXTRA_ICON_SMALL

Will get you the resource-ID of the icon that matches the current battery-status:http://developer.android.com/reference/android/os/BatteryManager.html#EXTRA_ICON_SMALL

额外ACTION_BATTERY_CHANGED:   包含的资源ID整数   表示一个小状态栏图标   目前的电池状态。

Extra for ACTION_BATTERY_CHANGED: integer containing the resource ID of a small status bar icon indicating the current battery state.

然而,它总是返回相同的图标,无论实际的电池电量是什么。查找图标由只想随机数可以工作,但我不知道该ID是整个SKD-水平以及不同的机器上是一致的,所以我宁愿不依赖于这一点。

However, it always returns the same icon, no matter what the actual battery level is. Finding the icon by just trying random numbers may work, but I don't know if the IDs are consistent throughout the SKD-levels as well as different machines, so I'd rather not rely in that.