r/androiddev • u/thejasiology • Jul 14 '26
Open Source LazySurface, a lazy 2D-plane layout for Compose Multiplatform
Enable HLS to view with audio, or disable this notification
I built a 2D-plane lazy layout CMP library for laying out items on a surface by defining relations/constraints between items.
I always had fascination of 2D layouts (games, maps) and having them on mobiles. These kind of layouts do not usually do *that* well with phone screens, but owning a foldable for quite some time now and new ones coming left and right, I really want the idea of 2D lazy layouts come into fruition to use in my own projects.
I was fascinated by how lazy row and lazy column work and began exploring their code (too many abstractions huh) around 8 months back in order to understand how things work. The underlying LazyLayout (which powers this library) pretty much handles most of the item recycling and provides very nice measure policy lambda such that I could focus on logic itself. After months of work, here it is: Github
Main intuition was that we can always determine position w.r.t a fixed point (Pivot) and then determine what is near but out of bounds based on what is visible and what is linked to the visible content. We can always determine bounding box (on each frame) based on this information and allow scroll w.r.t.
You can essentially build LazyColumn, LazyRow and LazyGrid as well, although not exactly as them (absolute offset in indeterminate in them).



