Reputation: 1036
currently, i have a screen where it has
LinearLayout as root
in this case which one is better option to go for when migrating to compose in terms of perfomance ?
A
Column as root
or
B
LazyColumn as root
Upvotes: 2
Views: 1709
Reputation: 6863
About performance, you see lazy items are destroyed as soon as they leave composition (swiped off the screen). Hence, if you have items that do bits of loading like fetching some data from the web or displaying an image loaded from internal assets, all that fetching will be re-executed upon re-entering. Although there will be caching automatically so you do not need to worry that the heavy operations will be re-executed, but the fetching will take place, even though it is from the cache. So if it is not necessary to make the contents scrollable, and if it is, the contents are not too many, it is viable to use Column instead. LazyColumn
is just a quick replacement for RecyclerView. In your normal android app, you would not use RecyclerView for such stuff will you? Just use the same concept since it offers the same performance as a Recyclerview.
Short Answer: It does not make much difference; performance impacts, if any, will be negligible. I would probably go for Column in this scenario, but its completely up to your convenience.
Upvotes: 3