Android Question [B4X] LayoutFile vs Code

Alexander Stolte

Expert
Licensed User
Longtime User
Hello,

I have often read that it is slower to use a layout file than to code it.
My example is a panel with 15 components in it. (Label,buttons, etc..)
If I used LazyLoading now, fast scrolling would be a problem.

Would it be a good idea to grab the layout file in a panel at startup and then load that panel instead of referencing the layou file? How can you speed up the process? Building the layout by code would be a massive amount of time.

Thanks Experts.
 

stevel05

Expert
Licensed User
Longtime User
Do you get any performance problems when loading a layout? 15 components isn't that many.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
I have try last week to implement LazyLoading in to my project, this works fine. But if i scroll fast, had the list performance problems. And this on a Oneplus 6 with 8GB RAM and a Snapdragon 845. I think it was because of that. The list was just 20 items long.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Your first post didn't mention that you were loading the layout into a list. Loading a single panel more than once should be avoided.

Did you run your test in release mode?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I haven't tried it. It would be useful if you could zip and post your example project. So we can see exactly how you are implementing it.
 
Upvote 0

npsonic

Active Member
Licensed User
No, Seems like I made a mistake while building. I have test it, i made the imageViews big in the example project and then i have Blurred the image, but the list scrolls smooth.
You can also improve performance considerably even more by using Picasso for ImageViews.

When LoadLayout is used just add holder bitmap and let the Picasso load real bitmap asynchronously.
If you decide to use Picasso with "lazy loading" remember to use Picasso method "cancelRequest" when removing not visible panels.
 
Upvote 0
Top