跪拜 Guibai
← Back to the summary

Modern Android Screen Adaptation: Three Layers, Not One Scale Factor

Modern Android Screen Adaptation: A Complete Guide

"One dp for everything" no longer works

In the past, adapting screens was simple: designers gave one set of mockups, we cut them into Android dp, and for landscape we wrote a separate layout-land. Done.

But today's device form factors have fragmented completely:

Form factor Typical example Width when unfolded/in use (dp) Adaptation difficulty
Small fold outer screen Vertical small fold closed state 320 ~ 360 Extremely narrow; content must be reduced
Normal straight phone Mainstream 6.1 ~ 6.8 inches 360 ~ 480 Aspect ratio 18:9 ~ 21:9
Wide straight phone 16:10 / 3:2 wide-screen phones 480 ~ 600 Width close to tablet, but still "phone"
Large fold unfolded Book-style inner screen 600 ~ 840 Hinge, posture, inner/outer screen switching
Wide fold 16:10 wide ratio foldable 600 ~ 900 Unfolded close to square; layout must reflow
Tablet 10 ~ 13 inches 840 ~ 1280+ Two/three columns, keyboard/mouse interaction
Free window / desktop mode Split-screen, floating windows, PC mode Any size Window changes in real time

So the core of adaptation is not finding a new "universal scale ratio", but building a responsive layout system: layout automatically chooses the most appropriate presentation based on available window size and folding state.

Measurement units and related concepts

px, dp, sp, dpi, density

Unit Meaning Use case
px Physical pixel Only for low-level drawing, image decoding, Canvas
dp Density-independent pixel Layout sizes, padding, corner radius, control sizes
sp Scale-independent pixel Text size (follows system font scaling)
dpi Pixels per inch Describes screen density level
density Density factor, dpi / 160 dp to px conversion

Core formula:

px = dp * density
sp = dp * fontScale  // fontScale: user font scaling factor

Example: a 1080px wide phone with density = 2.75 has width 1080 / 2.75 ≈ 393dp.

smallestWidth (sw) and available width (w)

For foldables, the w qualifier is more sensitive than sw. But neither is as precise as WindowSizeClass, because qualifiers only re-match when configuration changes; they cannot express continuous changes like "current window split into 500dp".

Configuration and window size

Fields relevant to adaptation in Configuration:

val config = resources.configuration
config.screenWidthDp       // current window width (dp)
config.screenHeightDp      // current window height (dp)
config.smallestScreenWidthDp
config.orientation         // PORTRAIT / LANDSCAPE
config.screenLayout        // SIZE_SMALL / NORMAL / LARGE / XLARGE
config.fontScale           // user font scaling
config.densityDpi

When window size, orientation, font scaling, or dark mode changes, by default the system recreates the Activity and re-matches resources.

flowchart TD
    A[Window size / fold state change] --> B[Configuration update]
    B --> C{Resource qualifier matching}
    B --> D{Layout re-inflate / Compose recomposition}
    B --> E{WindowSizeClass recalculation}
    C --> F[values-sw600dp / drawable-xxhdpi ...]
    D --> G[Single / dual / triple column]
    E --> G
    G --> H[Final UI]

The three-layer model of modern adaptation

Adaptation can be split into three layers, from bottom to top:

Layer 1: Resource layer

Use qualifiers to handle resource substitution for different densities, sizes, languages, themes.

Layer 2: Layout layer

Make the layout itself flexible, rather than relying on resource replacement.

Layer 3: Window layer

Make structural decisions based on window "size class" and folding posture.

Resource layer handles "pixel-level replacement", layout layer handles "flexibility", window layer handles "structure". All three together constitute complete modern adaptation.

Resource qualifiers

How to choose size qualifiers

Qualifier Meaning Recommended use
sw320dp smallest width >= 320dp fallback for very small screens
sw360dp smallest width >= 360dp baseline for mainstream phones
sw600dp smallest width >= 600dp tablets, unfolded foldables
sw720dp smallest width >= 720dp large tablets
w600dp current width >= 600dp split screen, free window
w840dp current width >= 840dp large tablets, desktop mode
h480dp current height >= 480dp landscape, desktop mode
land landscape supplementary only

Recommended order: sw determines device tier, w determines window tier, h helps with landscape/desktop mode.

dimens layered example

<!-- res/values/dimens.xml: phone defaults -->
<resources>
    <dimen name="page_padding_horizontal">16dp</dimen>
    <dimen name="page_padding_vertical">12dp</dimen>
    <dimen name="card_corner">12dp</dimen>
    <dimen name="content_max_width">600dp</dimen>
    <dimen name="list_item_height">72dp</dimen>
</resources>
<!-- res/values-sw600dp/dimens.xml: tablets / unfolded foldables -->
<resources>
    <dimen name="page_padding_horizontal">24dp</dimen>
    <dimen name="page_padding_vertical">16dp</dimen>
    <dimen name="card_corner">16dp</dimen>
    <dimen name="content_max_width">840dp</dimen>
    <dimen name="list_item_height">80dp</dimen>
</resources>
<!-- res/values-w840dp/dimens.xml: large tablets / desktop mode -->
<resources>
    <dimen name="page_padding_horizontal">32dp</dimen>
    <dimen name="content_max_width">1040dp</dimen>
</resources>

Layout qualifier example

<!-- res/layout/activity_main.xml: phone single-column -->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/list_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>
<!-- res/layout-sw600dp/activity_main.xml: two-column -->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/list_container"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2" />

    <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="?android:attr/listDivider" />

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/detail_container"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="3" />
</LinearLayout>

This approach suits pages with very different structures. But note: layout-sw600dp only switches when configuration changes; it cannot handle continuous size changes during split-screen dragging. Real dynamic adaptation still requires WindowSizeClass and Compose's constraint layout.

Image resource adaptation

res/
├── drawable-mdpi/ic_logo.png
├── drawable-hdpi/ic_logo.png
├── drawable-xhdpi/ic_logo.png
├── drawable-xxhdpi/ic_logo.png
└── drawable-xxxhdpi/ic_logo.png
  1. Prefer Vector Drawable: convert icons and simple illustrations from SVG; they are sharp at any density.
  2. Use WebP/AVIF for photos: much smaller than PNG, natively supported on Android.
  3. Full-screen background images need to consider aspect ratio: a 21:9 image and a 16:10 image cannot simply use fitXY; use centerCrop or ContentScale.Crop.

Density adaptation: is the Toutiao solution still worth using?

How it works

The essence of "Toutiao solution" is: regardless of the device's actual density, force the screen width to be converted to the design width (e.g., 375dp), then modify DisplayMetrics.density so that 1dp always equals 1px on the design mockup.

Designer gives a 375 design; you write width = 100dp, and on any phone it takes 100/375 of the screen width.

Core code:

object DensityAdapter {
    // Design width in dp. 375 corresponds to iPhone 6/7/8 logic width
    const val DESIGN_WIDTH_DP = 375f

    fun wrap(base: Context): Context = DensityContextWrapper(base)
}

private class DensityContextWrapper(base: Context) : ContextWrapper(base) {

    override fun getResources(): Resources {
        val resources = super.getResources()
        val config = Configuration(resources.configuration)
        val metrics = resources.displayMetrics

        val targetDensity = metrics.widthPixels / DensityAdapter.DESIGN_WIDTH_DP
        if (targetDensity > 0f && abs(targetDensity - metrics.density) > 0.01f) {
            config.densityDpi = (targetDensity * 160).toInt()
            metrics.density = targetDensity
            // Preserve system font scaling to avoid breaking after user enlarges text
            metrics.scaledDensity = targetDensity * config.fontScale
            @Suppress("DEPRECATION")
            resources.updateConfiguration(config, metrics)
        }
        return resources
    }
}

open class BaseActivity : AppCompatActivity() {
    override fun attachBaseContext(newBase: Context) {
        // Must replace before super.attachBaseContext so subsequent inflate uses new density
        super.attachBaseContext(DensityAdapter.wrap(newBase))
    }
}

Real problems with this solution

Problem Description
Multi-window failure displayMetrics.widthPixels in split-screen or free window is not necessarily the current window width
Foldable switch failure Density is cached after inner/outer switch, easy to miscalculate
System font scaling conflict If mishandled, sp breaks or fonts enlarge abnormally
Breaks system consistency User-set "display size" is bypassed, degrading accessibility

WindowSizeClass: the core of modern adaptation

WindowSizeClass is the official window-size classification standard from Android. It summarizes the infinite window sizes into a few discrete classes so UI can make structural decisions.

Category Width range Typical device Recommended layout
Compact < 600dp phone portrait, small fold outer screen single column + bottom navigation
Medium 600dp ~ 839dp unfolded foldable, small tablet portrait two columns / navigation bar
Expanded >= 840dp large tablet, desktop mode two or three columns

Height also has corresponding classes (Compact < 480dp, Medium 480 ~ 899dp, Expanded >= 900dp), mainly for landscape or desktop mode.

Computing WindowSizeClass

class MainActivity : ComponentActivity() {

    @OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            val windowSizeClass = calculateWindowSizeClass(this)
            App(windowSizeClass)
        }
    }
}

@Composable
fun App(windowSizeClass: WindowSizeClass) {
    when (windowSizeClass.widthSizeClass) {
        WindowWidthSizeClass.Compact -> PhoneLayout()
        WindowWidthSizeClass.Medium -> FoldableLayout()
        WindowWidthSizeClass.Expanded -> TabletLayout()
        else -> PhoneLayout()
    }
}

More recommended approach in Compose

material3-adaptive provides currentWindowAdaptiveInfo(), which updates automatically when the window changes without depending on Activity recreation.

@Composable
fun AdaptiveApp() {
    val adaptiveInfo = currentWindowAdaptiveInfo()
    val sizeClass = adaptiveInfo.windowSizeClass

    val isExpanded = sizeClass.isWidthAtLeastBreakpoint(
        WindowSizeClass.WIDTH_DP_EXPANDED_LOWER_BOUND // 840
    )
    val isMedium = sizeClass.isWidthAtLeastBreakpoint(
        WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND   // 600
    )

    when {
        isExpanded -> ThreePaneLayout()
        isMedium -> TwoPaneLayout()
        else -> SinglePaneLayout()
    }
}

If you don't want to memorize constants, you can wrap your own breakpoints.

object Breakpoints {
    const val COMPACT_MAX = 599
    const val MEDIUM_MAX = 839
    // 840 and above are Expanded
}

enum class WindowWidth { Compact, Medium, Expanded }

@Composable
fun rememberWindowWidth(): WindowWidth {
    val sizeClass = currentWindowAdaptiveInfo().windowSizeClass
    return when {
        sizeClass.isWidthAtLeastBreakpoint(840) -> WindowWidth.Expanded
        sizeClass.isWidthAtLeastBreakpoint(600) -> WindowWidth.Medium
        else -> WindowWidth.Compact
    }
}

Using WindowMetrics for true window size

Don't use Display.getMetrics() anymore; in multi-window it returns the physical screen, not your window.

fun Activity.windowSizeInDp(): Pair<Float, Float> {
    val bounds = WindowMetricsCalculator.getOrCreate()
        .computeCurrentWindowMetrics(this)
        .bounds
    val density = resources.displayMetrics.density
    return bounds.width() / density to bounds.height() / density
}

In Compose, use LocalWindowInfo.current.containerSize:

@Composable
fun WindowSizeLogger() {
    val windowInfo = LocalWindowInfo.current
    val density = LocalDensity.current
    val widthDp = with(density) { windowInfo.containerSize.width.toDp() }
    val heightDp = with(density) { windowInfo.containerSize.height.toDp() }
    Text("Current window: ${widthDp.value.toInt()} × ${heightDp.value.toInt()} dp")
}

Breakpoints are not law

600 / 840 are Material's recommended values, not mandatory standards. What really matters is content-driven design:

Breakpoints serve content, not the other way around.

Foldable practice: Jetpack WindowManager

The biggest difference between foldable adaptation and ordinary large-screen adaptation is the hinge and posture.

Three concepts

Folding feature state

State Meaning
FLAT Fully open, screen is flat
HALF_OPENED Half-opened, like a laptop or tent

Hinge orientation

Orientation Typical posture Layout strategy
VERTICAL Book mode (left-right split) Left and right columns, avoid hinge in middle
HORIZONTAL Desktop mode / tent mode (top-bottom split) Top and bottom columns, avoid hinge in middle

isSeparating

occlusionType

Listening to fold state

@Composable
fun rememberFoldingFeature(): FoldingFeature? {
    val context = LocalContext.current
    val activity = remember(context) { context.findActivity() } ?: return null

    val state = produceState<FoldingFeature?>(initialValue = null, activity) {
        WindowInfoTracker.getOrCreate(context)
            .windowLayoutInfo(activity)
            .collect { layoutInfo ->
                value = layoutInfo.displayFeatures
                    .filterIsInstance<FoldingFeature>()
                    .firstOrNull()
            }
    }
    return state.value
}

tailrec fun Context.findActivity(): Activity? = when (this) {
    is Activity -> this
    is ContextWrapper -> baseContext.findActivity()
    else -> null
}

Hinge avoidance: left/right or top/bottom split

This is the most core piece of code in foldable adaptation. The idea: convert FoldingFeature.bounds from screen coordinates to window coordinates, then insert a Spacer at the hinge position to divide content into two sides.

@Composable
fun HingeAwareLayout(
    feature: FoldingFeature?,
    firstPane: @Composable () -> Unit,
    secondPane: @Composable () -> Unit,
) {
    val activity = LocalContext.current.findActivity()

    // No fold feature, or hinge doesn't separate: single pane
    if (feature == null || !feature.isSeparating || activity == null) {
        Box(Modifier.fillMaxSize()) { firstPane() }
        return
    }

    // Convert screen coordinates -> window coordinates (window origin isn't necessarily 0,0 in multi-window/free-window)
    val windowBounds = remember(activity) {
        WindowMetricsCalculator.getOrCreate()
            .computeCurrentWindowMetrics(activity)
            .bounds
    }
    val hinge = remember(feature, windowBounds) {
        Rect(feature.bounds).apply {
            offset(-windowBounds.left, -windowBounds.top)
        }
    }

    val density = LocalDensity.current

    when (feature.orientation) {
        FoldingFeature.Orientation.VERTICAL -> {
            // Book mode: left-right split
            Row(Modifier.fillMaxSize()) {
                Box(
                    Modifier.width(with(density) { hinge.left.toDp() })
                ) { firstPane() }

                Spacer(
                    Modifier
                        .width(with(density) { hinge.width().toDp() })
                        .fillMaxHeight()
                )

                Box(Modifier.weight(1f)) { secondPane() }
            }
        }

        else -> {
            // Desktop mode / tent mode: top-bottom split
            Column(Modifier.fillMaxSize()) {
                Box(
                    Modifier.height(with(density) { hinge.top.toDp() })
                ) { firstPane() }

                Spacer(
                    Modifier
                        .height(with(density) { hinge.height().toDp() })
                        .fillMaxWidth()
                )

                Box(Modifier.weight(1f)) { secondPane() }
            }
        }
    }
}

Usage example:

@Composable
fun MailScreen() {
    val feature = rememberFoldingFeature()

    HingeAwareLayout(
        feature = feature,
        firstPane = { MailList() },
        secondPane = { MailDetail() }
    )
}

FoldingFeature.bounds are screen coordinates. If your Activity is in split-screen or free window, using them directly causes offset. The code above converts via WindowMetricsCalculator; this step cannot be skipped.

Application continuity: don't lose state on inner/outer switch

One of the most annoying things for foldable users: close the cover and open it again, the page returns to home, form content is all gone.

Several points to ensure continuity:

Make Activity resizable

<application>
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:resizeableActivity="true" />
</application>

Don't use configChanges to forcibly prevent recreation

<!-- ❌ Not recommended: suppressing recreation often leads to layout not refreshing, resources not re-matching -->
<activity
    android:name=".MainActivity"
    android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboardHidden" />

Correct approach: let the system recreate, then preserve state with ViewModel + SavedStateHandle:

class EditorViewModel(
    private val savedStateHandle: SavedStateHandle
) : ViewModel() {

    // Auto-saved, restores even after process death
    var draft: String
        get() = savedStateHandle["draft"] ?: ""
        set(value) { savedStateHandle["draft"] = value }
}

In Compose use rememberSaveable:

@Composable
fun EditorScreen(viewModel: EditorViewModel = viewModel()) {
    var text by rememberSaveable { mutableStateOf(viewModel.draft) }

    TextField(
        value = text,
        onValueChange = {
            text = it
            viewModel.draft = it
        },
        modifier = Modifier.fillMaxWidth()
    )
}

Video and audio should save playback position

class PlayerViewModel : ViewModel() {
    var positionMs: Long = 0L
    var isPlaying: Boolean = false
}

Record in onStop() or on configuration change, restore in onStart().

Avoid storing Activity in a singleton

// ❌ Memory leak + points to old Activity after configuration change
object Holder {
    var activity: Activity? = null
}

Android 15/16 large-screen rules

System updates in the last two years have imposed hard requirements for adaptation:

Android 15 (API 35)

Android 16 (API 36)

This means:

<!-- ❌ Will not work on large screens, and violates large-screen app quality guidelines -->
<activity
    android:name=".MainActivity"
    android:screenOrientation="portrait"
    android:resizeableActivity="false" />

Correct approach:

<!-- ✅ No orientation restriction, allows resizing -->
<activity
    android:name=".MainActivity"
    android:screenOrientation="unspecified"
    android:resizeableActivity="true" />

Then in code use WindowSizeClass to handle portrait/landscape and window changes, instead of assuming "phone is always portrait".

Edge-to-edge and Insets

After Android 15, edge-to-edge is default. You need:

Use WindowInsets to reserve safe area for content:

Scaffold(
    modifier = Modifier.fillMaxSize(),
    contentWindowInsets = WindowInsets.safeDrawing
) { innerPadding ->
    Content(Modifier.padding(innerPadding))
}

Or finer-grained control:

Box(
    Modifier
        .fillMaxSize()
        .windowInsetsPadding(WindowInsets.statusBars)
        .imePadding()
) {
    // content
}

Common insets:

Insets Meaning
WindowInsets.statusBars Status bar
WindowInsets.navigationBars Navigation bar
WindowInsets.ime Soft keyboard
WindowInsets.displayCutout Notch / punch hole
WindowInsets.safeDrawing Union of all above safe areas
WindowInsets.safeGestures Gesture area

Notch/punch-hole screens

<!-- res/values/themes.xml -->
<style name="Theme.App" parent="Theme.Material3.DayNight.NoActionBar">
    <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>

Three modes:

Mode Behavior
default Uses cutout area in portrait, not in landscape
shortEdges Can extend into cutout area on short edges (most common)
never Doesn't use cutout area
always Always uses cutout area (API 30+)

In Compose, get cutout safe area:

val cutout = WindowInsets.displayCutout
Box(
    Modifier
        .fillMaxSize()
        .windowInsetsPadding(cutout)
) { ... }

Compose reactive layout practice

BoxWithConstraints: local responsiveness

BoxWithConstraints tells you the currently available space, good for local self-adaptation:

@Composable
fun ProductSection(products: List<Product>) {
    BoxWithConstraints(Modifier.fillMaxWidth()) {
        val columns = when {
            maxWidth < 400.dp -> 1
            maxWidth < 720.dp -> 2
            maxWidth < 1000.dp -> 3
            else -> 4
        }

        LazyVerticalGrid(
            columns = GridCells.Fixed(columns),
            contentPadding = PaddingValues(16.dp),
            horizontalArrangement = Arrangement.spacedBy(12.dp),
            verticalArrangement = Arrangement.spacedBy(12.dp),
            modifier = Modifier.fillMaxSize()
        ) {
            items(products) { product ->
                ProductCard(product)
            }
        }
    }
}

A lazier approach is to let content decide column count:

LazyVerticalGrid(
    columns = GridCells.Adaptive(minSize = 160.dp),
    contentPadding = PaddingValues(16.dp),
    horizontalArrangement = Arrangement.spacedBy(12.dp),
    verticalArrangement = Arrangement.spacedBy(12.dp)
) {
    items(products) { ProductCard(it) }
}

GridCells.Adaptive(160.dp) means: each column at least 160dp, as many columns as fit. Phone 2 columns, tablet 5, unfolded fold 4, no breakpoints needed.

Limit content maximum width

On large screens, the worst thing is "text spanning 1200dp". Reading and form pages must limit max width:

@Composable
fun ReadableContainer(
    maxWidth: Dp = 680.dp,
    content: @Composable () -> Unit
) {
    Box(
        modifier = Modifier.fillMaxSize(),
        contentAlignment = Alignment.TopCenter
    ) {
        Box(
            modifier = Modifier
                .widthIn(max = maxWidth)
                .fillMaxWidth()
        ) {
            content()
        }
    }
}

@Composable
fun ArticleScreen(article: Article) {
    ReadableContainer(maxWidth = 680.dp) {
        Column(Modifier.padding(horizontal = 16.dp)) {
            Text(article.title, style = MaterialTheme.typography.headlineMedium)
            Text(article.body, style = MaterialTheme.typography.bodyLarge)
        }
    }
}

ListDetailPaneScaffold: official two-pane solution

Material 3 Adaptive provides an out-of-the-box list-detail layout that automatically decides based on window width:

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
fun MailApp(mails: List<Mail>) {
    val navigator = rememberListDetailPaneScaffoldNavigator<String>()

    BackHandler(enabled = navigator.canNavigateBack()) {
        navigator.navigateBack()
    }

    ListDetailPaneScaffold(
        directive = navigator.scaffoldDirective,
        value = navigator.scaffoldValue,
        listPane = {
            AnimatedPane {
                MailList(
                    mails = mails,
                    onMailClick = { mail ->
                        navigator.navigateTo(
                            ListDetailPaneScaffoldRole.Detail,
                            mail.id
                        )
                    }
                )
            }
        },
        detailPane = {
            AnimatedPane {
                val selectedId = navigator.currentDestination?.contentKey
                if (selectedId == null) {
                    EmptyDetailPlaceholder()
                } else {
                    MailDetail(mailId = selectedId)
                }
            }
        }
    )
}

Adaptive navigation: bottom bar vs navigation bar

Don't manually judge width to switch between NavigationBar and NavigationRail; use the official suite:

@Composable
fun MainScaffold() {
    var selected by rememberSaveable { mutableStateOf(0) }

    NavigationSuiteScaffold(
        navigationSuiteItems = {
            item(
                selected = selected == 0,
                onClick = { selected = 0 },
                icon = { Icon(Icons.Default.Home, contentDescription = "Home") },
                label = { Text("Home") }
            )
            item(
                selected = selected == 1,
                onClick = { selected = 1 },
                icon = { Icon(Icons.Default.Person, contentDescription = "Profile") },
                label = { Text("Profile") }
            )
            item(
                selected = selected == 2,
                onClick = { selected = 2 },
                icon = { Icon(Icons.Default.Settings, contentDescription = "Settings") },
                label = { Text("Settings") }
            )
        }
    ) {
        when (selected) {
            0 -> HomeScreen()
            1 -> ProfileScreen()
            else -> SettingsScreen()
        }
    }
}

NavigationSuiteScaffold behavior:

Portrait/landscape differing layouts

@Composable
fun VideoScreen() {
    val configuration = LocalConfiguration.current
    val isLandscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE

    if (isLandscape) {
        Row(Modifier.fillMaxSize()) {
            Box(Modifier.weight(2f)) { VideoPlayer() }
            Box(Modifier.weight(1f)) { EpisodeList() }
        }
    } else {
        Column(Modifier.fillMaxSize()) {
            Box(Modifier.weight(1f)) { VideoPlayer() }
            Box(Modifier.weight(1f)) { EpisodeList() }
        }
    }
}

But width-based judgment is preferred over orientation:

BoxWithConstraints {
    if (maxWidth > 600.dp) {
        Row { VideoPlayer(); EpisodeList() }
    } else {
        Column { VideoPlayer(); EpisodeList() }
    }
}

Because an unfolded foldable can still be "portrait" but width already exceeds 600dp; using orientation would miss that case.

Font adaptation

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun PriceText(price: String) {
    BasicText(
        text = price,
        style = MaterialTheme.typography.headlineMedium,
        maxLines = 1,
        autoSize = TextAutoSize.StepBased(
            minFontSize = 12.sp,
            maxFontSize = 28.sp,
            stepSize = 1.sp
        )
    )
}

Wide phones, wide foldables, and small fold outer screens

The new form factors that have appeared in the last three years cannot simply be handled with a "phone / tablet" dichotomy:

Form factor Typical width Typical height Adaptation strategy
Small fold outer screen 320 ~ 360dp relatively short single column, simplified entry, must be scrollable
Normal straight phone 360 ~ 480dp very tall (18:9 ~ 21:9) single column + bottom navigation
Wide straight phone 480 ~ 600dp medium still Compact, can use two-column cards, but don't force two-pane
Wide fold unfolded 600 ~ 900dp may be short (near square) judge width + height together, prefer left-right split
Large fold / tablet 840dp+ tall two/three columns + navigation bar

Key point: width reaching Medium does not mean height is sufficient. A wide fold can unfold to 700dp width but only 600dp height; copying tablet's "top-bottom structure" will be cramped.

@Composable
fun WideDeviceLayout() {
    BoxWithConstraints(Modifier.fillMaxSize()) {
        val isWide = maxWidth >= 600.dp
        val isShort = maxHeight < 600.dp

        when {
            // Wide fold unfolded, landscape: wide and short, prefer left-right split
            isWide && isShort -> Row(Modifier.fillMaxSize()) {
                Box(Modifier.weight(1f)) { PrimaryContent() }
                Box(Modifier.weight(1f)) { SecondaryContent() }
            }

            // Tablet: wide and tall, left-right split with wider main content
            isWide -> Row(Modifier.fillMaxSize()) {
                Box(Modifier.weight(2f)) { PrimaryContent() }
                Box(Modifier.weight(1f)) { SecondaryContent() }
            }

            // Phone, small fold outer screen, wide straight: single column
            else -> Column(Modifier.fillMaxSize()) {
                PrimaryContent()
            }
        }
    }
}

Image ratios should change too. Continuing to use 16:9 banners on wide phones and wide foldables looks flat and empty:

@Composable
fun AdaptiveHeroImage(url: String) {
    BoxWithConstraints(Modifier.fillMaxWidth()) {
        val ratio = when {
            maxWidth >= 840.dp -> 21f / 9f
            maxWidth >= 600.dp -> 4f / 3f
            else -> 16f / 9f
        }
        Box(
            Modifier
                .fillMaxWidth()
                .aspectRatio(ratio)
        ) {
            AsyncImage(
                model = url,
                contentDescription = null,
                contentScale = ContentScale.Crop,
                modifier = Modifier.fillMaxSize()
            )
        }
    }
}

Also, a wide straight phone, though its width approaches 600dp, is still a "phone": system navigation, keyboard, notifications operate under phone logic. Don't replace bottom navigation with a navigation rail just because maxWidth reaches 560dp, unless content really needs it. Structure follows content, not numbers.