0PricingLogin
Jetpack Compose Academy · Lesson

Preserving Tab State on Switch

Keep each tab's scroll and state.

The Lost Scroll Problem

By default, leaving a tab and coming back rebuilds it from scratch, so your scroll position and inputs vanish. Annoying, right? 😅

Why It Happens

A plain navigate replaces the destination, so Compose forgets the old screen. Preserving state means telling navigation to save it instead.

All lessons in this course

  1. NavigationBar with Multiple Tabs
  2. Highlighting the Selected Route
  3. Preserving Tab State on Switch
  4. TabRow & Swipeable Pages
← Back to Jetpack Compose Academy