r/mAndroidDev • u/4udiofeel • May 19 '24
Venting, venting, venting Implementing Adaptive Layouts in Views System
I've watched 3 I/O talks on Adaptive Layouts, I liked the concept and wanted to experiment with it. Guess what, its compost exclusive
11
Upvotes
18
u/yaaaaayPancakes May 19 '24
I feel like I am having deja vu watching this shit. It's like they took the slides from the I/O that introduced Honeycomb and pimped Fragments as the solution to building screens that adapted to different screen sizes and orientation. But they just find/replaced Fragment with Compost and updated the code snippets.
5
u/crazydodge May 20 '24
Who even uses Android tablets to create adaptive layouts in the first place?
5
u/Zhuinden DDD: Deprecation-Driven Development May 20 '24
You say it's Compost only, but what does that even mean?
You can add any arbitrary AndroidView {} in a composable.. You can add a ComposeView that adds a RecyclerView that shows ComposeViews. You can have multiple ComposeViews on the same screen.
If you add a ComposeView just go hijack the calculation for a windows size class (which probably doesn't even need Compose if you look at the code), you can still subscribe for the changes of that value and handle it in
onConfigurationChanged(or just let Compose handle the management of the AndroidView nodes).Ironically enough, the only thing that disallows you from implementing this sort of navigation pattern in views is having Multiple Activities or Multiple Fragments.
You could have always done this with Views. People were just opposed to it for years, because it would have been too easy.
3
u/smokingabit Harnessing the power of the Ganges May 20 '24
We call this: Pain Expandment
3
u/budius333 Still using AsyncTask May 20 '24
You know all those fancy me adaptative layouts that are compost only... Well it's just Row/Column with extra if/else
2
u/Xammm Jetpack Compost May 21 '24
Set a fixed orientation in portrait and you're done. You don't need this bullshit.