Oliver Goossens Oliver Goossens - 1 year ago 89
Android Question

Changing drawable (PNG) in android application

I have a standard aplication. It uses resources - PNGs that are when programming in the DRAWABLE folder. They build up menus, buttons etc etc. ... Classic application nothing special.

And what I need to have is - "theme" support. Lets say I use this PNGs in my app:


and these are in the DRAWABLE folder.

And I would like to be able to change the THEME of the app by changing this PNGs for different ones. Lets say I have PNG's with same names, but under a different url:


and than I have a another "template"


IMPORTANT: Of course all the PNGs have exactly same size, and name

So and the app shall have the functionality to download this PNGs and replace the ones that are currently in use. The important point is that the additonal PNGs from different templates HAVE to be availiable online - I dont want to ship the app with many templates that would not be used.

Can you please confirm this can be done and that it should not be a problem?

Answer Source

The Drawable resources are packaged in to the application and cannot be modified. You idea of using an SD card will work (or you can use the applications sandboxed directory), you just need to manually load the png resources (ex. myImageView.setBackgroundBitmap(...); [pseudo-code]).

As a note: If I ever open an application that immediately tells me to wait since it is downloading resources, I will force-close it and uninstall. Applications on Android, iOS, Windows, etc. should work right away without the need to download more resources. If you want a default "theme" then package it with the app, don't make the user download it (which will cause problems if the user is on mobile networks or doesn't have an internet connection when they open the app)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download