Android Question xml.GetDrawable vs. LoadBitmapResize

leitor79

Active Member
Licensed User
Longtime User
Hi,

Yesterday I've pasted a code example using the XmlLayoutBuilder.GetDrawable and I get as feedback that it is not needed to use it, but to use LoadBitmapResize instead.

I remember a while ago reading some guidelines to material design, and I've found this here:

I prefer to use drawables for action icons than use the LoadBitMap() function. The drawables are available in different resolutions and will always load in the perfect size for your device. To load drawables you will have to use the XmlLayoutBuilder library.

I think I'm asking if something has has changed since corwin42 said that (like the new LoadBitmapResize) or why is preferred to use LoadBitmapResize instead.

Thank you very much!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Both options are good. As a general concept, B4A mostly doesn't use Android resources and therefore I recommend you to add the images to the Files folder. It is simpler and better integrated in B4A.

You can read more about LoadBitmapResize here: LoadBitmap / LoadBitmapResize / LoadBitmapSample
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi Erel, yhank you very much for answering.

I was aware that using LoadBitmapXXX was easier; I've switched to the GetDrawabe because I liked that thing of loading the image that fits better for the screen resolution.

As I interpet, with the GetDrawabe I can have several resolutions of the same image and, according to the device used, the most-suitable one will be loaded. This allows to optimize resources (load, memory) by not having to have the biggest images possible for the biggest screen available loaded every time and downscaled for smaller devices; am I right? Or which are the scenarios where the GetDrawable is better suited for?

Thank you very much!
 
Upvote 0
Top