leanback-to-compose-tv-migration

Migrates Android TV apps from Leanback UI Toolkit to Jetpack Compose for TV.

7.1k|466|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/android/skills --skill leanback-to-compose-tv-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: leanback-to-compose-tv-migration
Source: https://github.com/android/skills/tree/main/tv/leanback-to-compose-tv-migration
Command: npx skills add https://github.com/android/skills --skill leanback-to-compose-tv-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Migrating Android TV applications from the legacy Leanback UI Toolkit, Android Views, and Support Fragments to Jetpack Compose for TV (androidx.tv) involves complex architectural decisions, D-pad focus handling, and media playback modernization that LLMs frequently get wrong.

Core Features & Use Cases

  • Component Mapping: Provides a complete mapping table from legacy classes (BrowseSupportFragment, VideoSupportFragment, GuidedStepSupportFragment, ArrayObjectAdapter) to modern Compose equivalents (BrowseScreen, PlaybackScreen, LazyRow).
  • D-pad Focus Management: Enforces correct patterns for initial focus with FocusRequester, row focus memory with Modifier.focusRestorer, IME focus chaining, and Back-key interception to avoid focus traps.
  • Media3 Playback Modernization: Guides replacement of PlaybackGlue and PlayerView wrappers with Compose PlayerSurface and Media3 transport controls (PlayPauseButton, SeekBackButton, SeekForwardButton).
  • Use Case: When asked to migrate a TV app's browse screen from BrowseSupportFragment, the agent produces an immersive LazyColumn of LazyRows with a dynamic hero backdrop, pivot scrolling via BringIntoViewSpec, and proper focus restoration.

Quick Start

Ask your agent to migrate your Android TV app's Leanback browse screen to Jetpack Compose for TV using this skill.

Frequently Asked Questions about leanback-to-compose-tv-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate BrowseSupportFragment to Jetpack Compose for TV?

Replace BrowseSupportFragment with a BrowseScreen composable built from a LazyColumn containing categorized LazyRows and a hero banner. Use androidx.tv.material3 cards like CompactCard with focus scaling, and attach Modifier.focusRestorer to each LazyRow for focus memory.

What replaces VideoSupportFragment in Compose for TV?

VideoSupportFragment and PlaybackGlue are replaced by a PlaybackScreen using Media3 ExoPlayer with androidx.media3.ui.compose.PlayerSurface. Layer a translucent bottom overlay with PlayPauseButton, SeekBackButton, and SeekForwardButton from media3-ui-compose-material3.

Should I use androidx.compose.material3 or androidx.tv.material3 for TV apps?

Always use androidx.tv.material3 (androidx.tv:tv-material) for TV apps instead of mobile androidx.compose.material3. TV Material 3 provides built-in D-pad focus handling, focus zoom scaling, and TV-optimized typography, and mixing both libraries causes inconsistent theming.

Why does D-pad navigation crash with IllegalStateException in Compose TV lists?

This happens when directional focus overrides target items inside lazy containers that scroll off-screen, leaving their FocusRequester uninitialized. Rely on Compose's 2D spatial focus engine and attach Modifier.focusRestorer with no arguments directly to LazyRow instead.

Can I wrap PlayerView in AndroidView for Compose TV playback?

No, wrapping legacy PlayerView or StyledPlayerView in AndroidView is prohibited in this migration approach. Use PlayerSurface from androidx.media3.ui.compose with ExoPlayer, and handle D-pad seeking via onPreviewKeyEvent with Compose Key.DirectionLeft and Key.DirectionRight.

How do I handle Back button presses in TV text input fields?

Attach Modifier.onPreviewKeyEvent to the text field or its Surface wrapper and intercept Key.Back and Key.Escape on KeyUp to clear focus instead of exiting the screen. This lets users return to D-pad form navigation without leaving the screen.