简体   繁体   中英

Create Drawable at Runtime and add into Resources

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?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM