How Chromium Adapts its Tab Strip on Foldable Androids
This article provides an overview of how the Chromium web browser dynamically adjusts its tab strip user interface when a foldable Android device transitions between folded (phone) and unfolded (tablet) postures. It covers the screen width thresholds that trigger the layout change, the specific UI components that are swapped during the transition, and how the browser maintains the user's active session without reloading webpages.
The 600dp Threshold Trigger
Chromium does not rely on specific hardware sensors to know if a phone is folded or unfolded. Instead, it relies on Android's window size metrics, specifically the density-independent pixel (dp) width of the app window.
The critical breakpoint in Chromium is 600dp:
- Phone Posture (Under 600dp): When the device is folded, the screen width falls below 600dp. Chromium renders its compact mobile interface.
- Tablet Posture (600dp and Above): When the device is unfolded, the screen width exceeds 600dp. Chromium switches to its tablet interface, which includes a desktop-style horizontal tab strip at the top of the screen.
UI Components in Different Postures
Chromium uses different layout managers depending on the current screen width.
In the folded phone posture, horizontal space is limited. Chromium hides the tab strip completely. To manage tabs, the browser displays a small square icon with a number inside it on the main toolbar. Tapping this icon opens the full-screen Grid Tab Switcher.
In the unfolded tablet posture, Chromium activates the
StripLayoutHelperManager. This component draws a
persistent, scrollable horizontal tab strip directly above the address
bar (omnibox). Users can switch, close, or reorder tabs directly from
this strip, mimicking the desktop browser experience.
Handling the Posture Transition
When a user folds or unfolds their device, the Android operating
system triggers a configuration change
(onConfigurationChanged). Chromium handles this transition
through the following steps to ensure a seamless experience:
- Intercepting the Resize Event: Rather than letting Android completely destroy and restart the app from scratch, Chromium intercepts the configuration change and evaluates the new window dimensions.
- Swapping Toolbar Layouts: Chromium's
ToolbarManagerswaps the active toolbar implementation. When unfolding, it transitions fromToolbarPhonetoToolbarTablet. - Toggling the Tab Strip Visibility: The
StripLayoutHelperManagerlistens for the screen width change. Once the width crosses the 600dp threshold, it alters the visibility of the tab strip view, rendering it on the screen using hardware-accelerated animations. - Preserving the Tab Model: Throughout the
transition, the underlying data structure holding the open tabs—known as
the
TabModel—remains untouched in the device's memory. When the tab strip appears, it simply reads the existingTabModelto generate the visual tabs. Because the data model is preserved, the active webpage does not need to reload, and the user does not lose their scroll position or typed data.
Multi-Window and Split-Screen Adaptations
Because Chromium bases its UI on the app's window width rather than the physical state of the hinge, the tab strip also adapts during multitasking.
If a user unfolds their device into tablet posture, the tab strip appears. However, if the user then launches another app in split-screen mode, shrinking Chromium's allotted window width below 600dp, Chromium will dynamically hide the tab strip and revert to the phone UI. Once the user exits split-screen mode and Chromium regains the full unfolded screen width, the tab strip is instantly restored.