DEV Community

Cover image for # 🪟 Window Size Class: Migrating from androidx.window to Material 3 Adaptive
Marlon López
Marlon López

Posted on

# 🪟 Window Size Class: Migrating from androidx.window to Material 3 Adaptive

(Cover image: Window size class representations based on width, courtesy of Google)

Spanish version: Here.

In recent years, the Android ecosystem has increasingly embraced adaptive design. From the rise of foldable devices to large screens, managing the window size (WindowSizeClass) became key to offering seamless experiences across any form factor.

With the arrival of Material 3 Adaptive, Google proposes a new way to handle window size classes, integrating this concept directly into the Material Design libraries.

In this article, I want to share my experience migrating from androidx.window to the new Material 3 API, the challenges I encountered, and the advantages this change brings.

🧩 1. Context: The Previous Approach (androidx.window)

Until recently, the most common way to calculate size classes was using:

import androidx.window.layout.WindowMetricsCalculator

val metrics = WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(activity)
val width = metrics.bounds.width()
val height = metrics.bounds.height()
Enter fullscreen mode Exit fullscreen mode

The size class (compact, medium, expanded) was then derived manually or by using the WindowSizeClass extension from androidx.compose.material3.windowsizeclass.
This worked well, but it required manual configuration and was somewhat separate from modern Material 3 practices.

🧱 2. Material 3 Adaptive: The New Path

Material 3 introduces a new unified API for handling adaptive layouts, better integrating size classes with design components.

Now you can use:

import androidx.compose.material3.adaptive.WindowAdaptiveInfo
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
val adaptiveInfo = currentWindowAdaptiveInfo()
val windowSizeClass = adaptiveInfo.windowSizeClass
Enter fullscreen mode Exit fullscreen mode

This simplifies access to the current window size and connects it with other elements of the adaptive system (e.g., NavigationSuiteScaffold or PaneScaffold).

🔄 3. The Migration Process

During the migration, the main steps were:

  1. Remove androidx.window dependencies (e.g., androidx.window:window or androidx.window:window-java).
  2. Update Material 3 dependencies to a version that supports adaptive features.
  3. Replace metric calculation functions with the use of currentWindowAdaptiveInfo().
  4. Adjust breakpoints if you were using custom values.

💡 4. Benefits of the New Approach

  • ✅ Direct integration with Material 3 adaptive components.
  • 🧭 Less boilerplate: no need to calculate metrics manually.
  • 💥 Better future support for foldable screens and multitasking.
  • 🧩 Visual cohesion: Material 3 adapts interfaces more easily based on size.

⚠️ 5. Considerations and Limitations

  • Some advanced androidx.window functions (like FoldingFeature) may still require
  • additional code.
  • Full support depends on the version of Compose and Material 3 libraries.
  • It is still evolving, so there may be minor changes in the APIs.

🚀 6. Conclusion

The migration to Material 3 Adaptive is not only straightforward but also aligns your app with the future of adaptive design on Android.
If you are already using WindowSizeClass, the change will allow you to maintain a cleaner, modern, and more scalable foundation.

Top comments (0)