Sitemap
Android Expert

Android Expert

Android Engineer & Kotlin Advocate. 🚀 Deep dives into Jetpack Compose, Coroutines, and Clean Architecture. Turning complex code into scalable solutions. 🛠️✨

Member-only story

movableContentOf: How Compose Preserves State Across Layout Restructures

20 min readSep 27, 2026
Press enter or click to view image in full size
movableContentOf: How Compose Preserves State Across Layout Restructures

Not a Medium Member? “Read For Free”

You unfold a foldable phone mid-video. The single-pane layout widens smoothly into a dual-pane one — but underneath that animation, something breaks: the video flashes black, the buffer empties, and playback jumps back to the start.

Or: someone’s mid-sentence in a chat app when the screen switches to split view. Their cursor vanishes, the keyboard dismisses, and the draft they were typing disappears.

Both bugs share one root cause, and it isn’t a bug in your code — it’s a fundamental property of how Compose tracks state, which is also what makes movableContentOf the fix for both.

1. Why Compose Forgets State by Default

Mental model: Compose tracks position, not identity.

A composable call doesn’t return an object you can hold onto and reattach elsewhere. The Compose compiler assigns each call site a key, and at runtime the Composer writes into an append-only structure called the Slot Table based on the compiler-generated call-site key, execution order relative to sibling slots, and the parent group the call occurs under.

In other words: your state’s address is its structural location in the slot table…

--

--

Android Engineer & Kotlin Advocate. 🚀 Deep dives into Jetpack Compose, Coroutines, and Clean Architecture. Turning complex code into scalable solutions. 🛠️✨