Thanks for all your feedback from using the alphas to help bring Compose for TV to the stable release! It’s terrific that you’ve been using Compose in your TV apps — then you’ve seen how Compose is the best way to build user interfaces across all form factors in Android and how it simplifies and accelerates app development with customization and styling through a modern, declarative syntax in Kotlin.
Perhaps you’ve noticed that we’ve shifted a few things around when Compose for TV graduated out of alpha. Read on to learn how to migrate your code with those changes.
Compose for TV consists of two AndroidX Jetpack libraries:
androidx.tv.material3
is now stable in version 1.0.0androidx.tv.foundation
remains in alpha
Now that Compose for TV has graduated from alpha, we’ve promoted tv-material
to stable and moved the scrollable containers in tv-foundation
to where they belong: in compose-foundation
itself. The latest alpha version of the tv-foundation
library simply marks those components as deprecated. TvImeOptions continues to reside in tv-foundation
.
Based on developer feedback, we’ve modified various APIs, which means some things have been renamed, moved, or removed completely. While the comprehensive list is documented in the library release notes, here are the primary changes to help you migrate.
APIs that have been renamed
NonInteractiveSurfaceDefaults
andNonInteractiveSurfaceColors
have been renamed toSurfaceDefaults
andSurfaceColors
.StandardCardLayout
andWideCardLayout
have been renamed toStandardCardContainer
andWideCardContainer
.CardDefaults.ContainerGradient
has been renamed toCardDefaults.ScrimBrush
.
APIs that have changed
ListItem
parameters have been rearranged and renamed to require providingheadlineContent
.TvLazyRow
,TvLazyColumn
,TvLazyHorizontalGrid
andTvLazyVerticalGrid
have been removed because their functionality has been incorporated into the scrollable containers in compose-foundation version 1.7.0-beta02.
The supporting classesTvLazyListState
andTvGridCells
together with the methodsrememberTvLazyListState
andrememberTvLazyGridState
have also been replaced with the Compose foundation versions.
You can migrate by simply removing the tv-foundation dependency; you can find everything you need inandroidx.compose.foundation.lazy
by simply swapping all your composables with the non-TV counterpart; for example replacingTvLazy*
withLazy*
andrememberTvLazy*State
withrememberLazy*State
.
APIs that have been removed
CardContainerDefaults.ImageCard
has been removed; you can use a Card and contain an image inside it as demonstrated in JetStream’s MovieCard.ListItemDefaults.ListItemShape
,ListItemDefaults.FocusedDisabledBorder
&ListItemDefaults.SelectedContainerColorOpacity
are now private as they are not defaults for the ListItem composable.ImmersiveList
has been removed due to the limitations in the variety in the data types that represent content. Instead, you can create an immersive list with just a few lines of code (a complete snippet is available in the immersive list sample):
- With the migration of
TvLazy*
toLazy*
, scrollable containers no longer support thepivotOffset
parameter. If your application uses pivot offsets, You will need to define aBringIntoViewSpec
object implementing the pivot offset, and pass it to Lazy* withLocalBringIntoViewSpec
.
See thePositionFocusedItemInLazyLayout
snippet for a generic solution that allows specifying the offset ratio.