跪拜 Guibai
← All articles
Android · Android Jetpack

Jetpack Compose 1.13.0 Deprecates Form Input APIs, Stabilizes List Prefetch and Exit Snapshots

By 黄林晴 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The deprecation wave makes every Compose app with a custom input field or slider a migration target; the new stable APIs for list prefetch and exit animations remove long-standing workarounds for scroll jank and content disappearing during dismissals. Teams on older Compose versions need to plan the upgrade, especially with the requirement for Kotlin 2.2 and compileSdk 37.1.

Summary

Jetpack Compose 1.13.0 brings a wave of API deprecations that will touch nearly every form in existing apps. BasicTextField with onValueChange and VisualTransformation are deprecated, and the stateless overloads of Slider and RangeSlider are gone. The replacement is a state-driven model: TextField and OutlinedTextField now take TextFieldState, and formatting goes through InputTransformation and OutputTransformation. For length limits, maxLengthReject rejects an entire paste that would exceed the limit, while maxLengthTrim keeps only the characters that fit. The release also stabilizes LazyLayoutCacheWindow, allowing developers to configure how much content is prefetched ahead of and behind the scroll viewport. Defaults adapt to visible item sizes between 10% and 50% of the viewport for the ahead fraction, with no behind fraction unless configured.

New exit animation support comes via CapturedAnimatedVisibility, which releases the child composition immediately and draws a snapshot of the last frame during the exit phase, solving the common problem of content vanishing before the fade-out completes. Progressive blur via BlurRadiusSpec.verticalGradient lets developers apply a gradient blur to images on Android 13 and above. Foundation also adds PolygonShape and MorphPolygonShape for clipping and morphing shapes. Performance tooling improves with computedStateOf for recomposition only on value change, Perfetto tracing that records state reads and writes, and a UI test failure policy that saves screenshots and semantic trees.

Takeaways
— BOM 2026.11.01 requires Kotlin 2.2 or higher and compileSdk 37.1; use minorApiLevel to set the .1 in 37.1.
— BasicTextField(value, onValueChange) and VisualTransformation are deprecated; migrate to TextFieldState overloads.
— Stateless Slider and RangeSlider overloads are deprecated; use SliderState and RangeSliderState.
— InputTransformation and OutputTransformation split length/character enforcement from visual formatting; maxLengthReject rejects whole input over the limit, maxLengthTrim keeps as many characters as fit.
— LineHeightStyle.Mode.PerLine calculates per-line line heights to fix crowding from multilingual or mixed-size text.
— LazyLayoutCacheWindow is stable; pass it directly to LazyColumn/LazyVerticalGrid; default ahead fraction adapts between 10% and 50% of viewport, behind default is 0.
— CapturedAnimatedVisibility releases child composition on hide and shows a snapshot of the last frame during exit; use for immediate state clearing.
— Progressive blur requires API 33 for gradient blur; uniform blur from API 31.
— PolygonShape and MorphPolygonShape allow clipping and morphing to arbitrary polygon shapes.
— computedStateOf recomposes only when the value (e.g., Boolean) changes; derivedStateOf still caches expensive calculations.
— Perfetto recomposition tracing now records state reads/writes and call stacks; disable when measuring frame time.
— ComposeUiTestConfig.TestFailurePolicy saves screenshots and semantic trees on UI test failure.
Conclusions

The shift from value-driven to state-driven text fields signals a commitment to a single source of truth, reducing the need for side-effect management in forms.

CapturedAnimatedVisibility directly addresses the long-standing issue of exit animations showing empty containers; its snapshot approach is a pragmatic solution for stateless exit content.

LazyLayoutCacheWindow's default adaptive strategy means most lists won't need manual tuning; the manual API only matters for image-heavy lists where prefetch cost is measurable.

Concepts & terms
LazyLayoutCacheWindow
A configuration object for LazyColumn/LazyGrid that controls how much content is composed ahead of and behind the visible viewport, prefetching items to reduce scroll jank. Fractions are relative to viewport height.
CapturedAnimatedVisibility
An alternative to AnimatedVisibility that releases the child composition immediately when hidden and draws a static snapshot of the last frame during the exit animation, so you can clear state right away without losing visual content.
computedStateOf
A Compose state factory that recomputes its value each time it is read, and triggers recomposition only when the resulting value changes. Useful for low-cost calculations that depend on frequently changing state, like whether to show a back-to-top button.
InputTransformation / OutputTransformation
In Compose's new text field API, InputTransformation modifies the raw text as it is entered (e.g., enforcing length), while OutputTransformation applies visual changes (e.g., inserting spaces) without altering the stored state. This separation keeps the underlying value clean.
From the discussion
Featured comments
無表情

Just upgraded to 1.13, cachewindow is a bit like RecyclerView.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗