我正在尝试支持两个 Icon_Picker Intent :
org.adw.launcher.icons.ACTION_PICK_ICON
和
com.betterandroid.launcher2.icons.PICK_ICON_ACTION
不幸的是,ADW、Go Launcher 和 LauncherPro 使用上述 Intent 或使用在 /drawable
中查找的 XML 在 /drawable
中查找可绘制对象
而旧的 BetterAndroid intent 会扫描 /assets
文件夹中的图像。现在,我知道了用于从 XML 提供可绘制对象的可绘制对象的绝妙技巧:
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/com_aac_cachemate_demo_cachemate" />
</selector>
因此,我没有提供图形,而是指向现有图形 - 在引用相同图像但具有不同名称/ID 时不需要重复文件。
我的问题:
1) 当引用 /assets
而不是 drawable 时,是否有任何等效的技巧可以起作用?
2) 如果我要使用 AssetManager
读取 Assets 并使它们可绘制:
a) 它们是否可以通过 Intent 扫描这些可绘制对象来读取?
b) 应用程序的大小是否不可避免地会加倍?
c) 我将如何正确实现 AssetManager 才能使其正常工作?像这样的东西:
sampleimage= BitmapFactory.decodeResource(context.getResources(), R.drawable.sampleimage);
也许吧?或者从数组中获取 getAsset()
会有更好的选择吗?
我想要实现的不仅是将图像放在 /drawable
中,而且还以某种方式链接到 /assets
以便两者 Intent 可以扫描并找到可绘制对象并在其 GridView 中显示,而无需复制图形(将它们放在 Assets 和可绘制对象文件夹中。感谢您的帮助!
编辑:android: how to load xml file from assets directory?是一本非常有帮助的读物,但我不确定它是否完全排除了我想要实现的目标。任何/所有输入表示赞赏。
所以:看来我必须以另一种方式来做,如果它要起作用的话。 (另一种方式)意味着我需要将图形存储在 assets
文件夹中,然后使用 AssetManager
将它们放入 drawable
中。关于如何做到这一点的任何建议?有没有办法在 drawable
文件夹中使用 XML 来引用资源?
因此对我来说真正重要的问题,如果我要使用 AssetManager
读取 Assets 并使它们可绘制:
1) 它们是否可以通过 Intent 扫描这些可绘制对象来读取?
2) 应用大小是否不可避免地会加倍?
最佳答案
Is there any equivalent trick that would work when referencing the /assets instead of drawable?
不,对不起。
If I were to use AssetManager to read the assets and make them drawables
我将把这解释为创建 Drawable
Java 对象的意思。
a) Would they be readable by the Intent scanning for those drawables?
Intent
不会“扫描可绘制对象”,就像纸片写信或子弹射人一样。因此,我不知道你在说什么。此外,我怀疑唯一能够回答这个问题的人是您感兴趣的两个第三方应用程序的开发人员。哎呀,这两个 Intent
操作似乎都没有记录在案 - 这是整个 Internet 上唯一一个似乎提到 com.betterandroid.launcher2.icons.PICK_ICON_ACTION
的页面,基于 Google 搜索 - 因此这些应用程序的作者完全有可能没有在寻找你要做你想做的事。
b) Would the app size inevitably double in size anyway?
如果“大小”是指“磁盘上的大小”,那么不,在运行时读取内容不会增加磁盘空间。
c) How would I implement AssetManager correctly for this to work?
在 AssetManager
上调用 open()
以获取图像上的 InputStream
,然后将其传递给 BitmapFactory.decodeStream()
。
关于android - *有什么*方法可以将 Android/drawable 图形链接到/assets?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8602054/