Compose for TV is now stable in version 1.0

Migrating Jetpack Compose for TV from alpha to stable

Paul Lammertsma
Android Developers
Published in
3 min readSep 11, 2024

--

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.

What changed since alpha?

Compose for TV consists of two AndroidX Jetpack libraries:

  • androidx.tv.material3 is now stable in version 1.0.0
  • androidx.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.

The roadmap illustrates the history of both Compose for TV libraries starting in 2022. Parts of tv-foundation move to compose-foundation with only TvImeOptions remaining in 1.0.0-alpha. The tv-material library is shown to progress into beta in early 2024, then into RC, then stable as of today.
The Compose for TV roadmap

Hey, I was using that API! Where’d it go?

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 and NonInteractiveSurfaceColors have been renamed to SurfaceDefaults and SurfaceColors.
  • StandardCardLayout and WideCardLayout have been renamed to StandardCardContainer and WideCardContainer.
  • CardDefaults.ContainerGradient has been renamed to CardDefaults.ScrimBrush.

APIs that have changed

  • ListItem parameters have been rearranged and renamed to require providing headlineContent.
  • TvLazyRow, TvLazyColumn, TvLazyHorizontalGrid and TvLazyVerticalGridhave been removed because their functionality has been incorporated into the scrollable containers in compose-foundation version 1.7.0-beta02.
    The supporting classes TvLazyListState and TvGridCells together with the methods rememberTvLazyListState and rememberTvLazyGridState 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 in androidx.compose.foundation.lazy by simply swapping all your composables with the non-TV counterpart; for example replacing TvLazy* with Lazy* and rememberTvLazy*State with rememberLazy*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* to Lazy*, scrollable containers no longer support the pivotOffset parameter. If your application uses pivot offsets, You will need to define a BringIntoViewSpec object implementing the pivot offset, and pass it to Lazy* with LocalBringIntoViewSpec.
    See the PositionFocusedItemInLazyLayout snippet for a generic solution that allows specifying the offset ratio.

While this sounds like a lot of changes, you’ll see that most of the migration is just a matter of replacement.

If you’re looking for some inspiration, check out the updated samples for Jetstream and Jetcaster.

Missing anything or found a bug? Please submit feedback!

--

--