找回密码
 立即注册
ComponentTesteassoldrawableclass | android开发 2022-10-29 43 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
参考了一下百度的代码BaiduMapApi_Lib_Android_1.0.1.zip,总算有点端倪了,备检并共享一下。也挺简单的,现在主要说一下我碰到的问题。我的主意很简单,自定义一个组件,这个自定义组件就是一个LinearLayout,背景设置为一个图片,图片途径为:res/drawable/bg.png,通过出this.setBackgroundResource(R.drawable.bg)实现,依照上述的步骤输出为jar后,给另一个app调用,发现图片基本无法输出,老是显示调用者的默许Icon.反编了一下百度地图jar,发现它所有图片都是放在assets中,并不是放在res/drawable中,然后再检测了一下代码,其对图片的调用是通过AssetManager.open()方法来实现的,并非通过R.drawble来实现本资料共包括以下附件:
ComponentTest1\bin\com\eassol\componenttest1\ComponentTest1.class
ComponentTest1\bin\com\eassol\componenttest1\R$attr.class
ComponentTest1\bin\com\eassol\componenttest1\R$drawable.class
ComponentTest1\bin\com\eassol\componenttest1\R$id.class
ComponentTest1\bin\com\eassol\componenttest1\R$layout.class
ComponentTest1\bin\com\eassol\componenttest1\R$string.class
ComponentTest1\bin\com\eassol\componenttest1\R.class
ComponentTest1\bin\classes.dex
ComponentTest1\bin\ComponentTest1.apk
ComponentTest1\bin\resources.ap_
ComponentTest1\gen\com\eassol\componenttest1\R.java
ComponentTest1\libs\Component.jar
ComponentTest1\res\drawable-hdpi\icon.png
ComponentTest1\res\drawable-ldpi\icon.png
ComponentTest1\res\drawable-mdpi\icon.png
ComponentTest1\res\layout\main1.xml
ComponentTest1\res\values\strings.xml
ComponentTest1\src\com\eassol\componenttest1\ComponentTest1.java
ComponentTest1\.classpath
ComponentTest1\.project
ComponentTest1\AndroidManifest.xml
ComponentTest1\default.properties
ComponentTest1\proguard.cfg
.....

(Refer to Baidu's code BaiduMapApi_ Lib_ Android_ 1.0.1. Zip, we finally have a clue. Prepare for inspection and share. It's also very simple. Now I will mainly talk about the problems I have encountered. My idea is simple. Customizing a component is a LinearLayout. The background is set to an image. The image path is: res/drawable/bg.png. It is implemented by issuing this. setBackgroundResource (R.drawable. bg). After the component is output as a jar according to the above steps, it is called by another app. It is found that the image cannot be output and the caller's tacit Icon is always displayed Decompiled Baidu Maps jar, and found that all its pictures were placed in assets, not res/drawable, and then checked the code. Its call to pictures was implemented through the AssetManager. open() method, not through R.drawble. This material includes the following attachments:
ComponentTest1\bin\com\eassol\componenttest1\ComponentTest1.class
ComponentTest1\bin\com\eassol\componenttest1\R$attr.class
ComponentTest1\bin\com\eassol\componenttest1\R$drawable.class
ComponentTest1\bin\com\eassol\componenttest1\R$id.class
ComponentTest1\bin\com\eassol\componenttest1\R$layout.class
ComponentTest1\bin\com\eassol\componenttest1\R$string.class
ComponentTest1\bin\com\eassol\componenttest1\R.class
ComponentTest1\bin\classes.dex
ComponentTest1\bin\ComponentTest1.apk
ComponentTest1\bin\resources.ap_
ComponentTest1\gen\com\eassol\componenttest1\R.java
ComponentTest1\libs\Component.jar
ComponentTest1\res\drawable-hdpi\icon.png
ComponentTest1\res\drawable-ldpi\icon.png
ComponentTest1\res\drawable-mdpi\icon.png
ComponentTest1\res\layout\main1.xml
ComponentTest1\res\values\strings.xml
ComponentTest1\src\com\eassol\componenttest1\ComponentTest1.java
ComponentTest1\.classpath
ComponentTest1\.project
ComponentTest1\AndroidManifest.xml
ComponentTest1\default.properties
ComponentTest1\proguard.cfg
.....)

[下载]15513060596.rar




上一篇:AndroidManifest.xml小结
下一篇:Android 背景图片重复利用