Create Drawable at Runtime and add into Resources

纵然是瞬间 提交于 2019-12-12 02:08:41

问题


I create Drawable for my Android application at runtime. These Drawables are generated from font icon FontAwesome. I'm searching a way to add these drawables into Resources of my Android project. I would like to generate drawables at start of the application and use them in the rest of the application by accessing through resources.

Is it possible to add a drawable object into project resources in Java code?


回答1:


You can't add a drawable to your project resources at runtime. These are compiled into your APK when you create the app. What you can do is create the drawable at runtime and hold a reference to it for as long as you need it to be reused throughout the application lifecycle (of course, make sure you don't accidentally leak any memory if you choose this route).



来源:https://stackoverflow.com/questions/26612102/create-drawable-at-runtime-and-add-into-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!