leanback-to-compose-tv-migration
Skill này làm gì
Skill này hướng dẫn chuyển ứng dụng Android TV từ bộ công cụ giao diện Leanback, Views hoặc support fragment sang Jetpack Compose cho TV. Nó bao quát các màn hình như duyệt, cài đặt, đăng nhập và phát video. Nó dành cho lập trình viên Android TV đang hiện đại hóa ứng dụng.
Khi nào nên dùng
- ✓Khi ứng dụng Android TV của bạn dùng Leanback và bạn muốn chuyển sang Jetpack Compose cho TV.
- ✓Khi bạn cần chuyển màn hình duyệt, cài đặt hoặc đăng nhập TV sang Compose.
- ✓Khi bạn muốn màn hình TV được thiết kế để xem từ xa và điều hướng bằng điều khiển từ xa.
Liên kết skill
https://github.com/android/skills/blob/main/tv/leanback-to-compose-tv-migration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Chuyển màn hình duyệt của ứng dụng Android TV từ Leanback sang Jetpack Compose cho TV.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill làm theo các mẫu kiến trúc của thư viện androidx.tv, tập trung vào chữ lớn dễ đọc, độ tương phản cao và điều hướng bằng D-pad. Sau đó nó xây các bố cục tùy chỉnh như nền hero và ngăn điều hướng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
The 10-foot UI
A "10-foot UI" is a design paradigm for televisions that tailors an interface for viewing from approximately 3 meters (10 feet) away. When designing for this experience, account for these key characteristics:
- Viewing distance: Viewers are sitting far from the screen, "leaning back". Screen layouts are uncluttered, with text and UI elements that are large enough to be comfortably readable from a distance, without dense blocks of text.
- Color contrast: To avoid washed out colors on TV displays with low contrast ratios, the design uses high-contrast palettes and distinct visual indicators so focused states remain visible across different TV panels.
- D-pad navigation : Interaction relies on a directional remote control with limited 4-way navigation (
Up,Down,Left,Right) with components organized into clear spatial grids and carousels without focus traps.
Core architecture and library selection
When migrating an Android TV application to Jetpack Compose, you must use
androidx.tv libraries and follow these 10-foot UI patterns:
- UI modernization: Focus on custom, cinematic layouts over legacy direct 1:1 templates. You must use Jetpack Compose for TV features like dynamic gradient hero backdrops, custom focus animations, custom navigation drawers, and custom layouts.
- Primary design system : You must always use
androidx.tv.material3.*(androidx.tv:tv-material) over mobileandroidx.compose.material3.*. TV Material 3 provides built-in D-Pad focus handling, focus zoom scaling, and TV-optimized typography and shapes. To set up Compose for TV dependencies, follow Compose for TV setup. - Focus zoom animation : For interactive cards, you must use
CompactCard,ClassicCard, orWideCardContainerwithscale = CardDefaults.scale(focusedScale = 1.1f)to provide standard TV focus animation. - Coil image loading : To use declarative
AsyncImage(model, contentDescription, ...)without passing an explicitImageLoaderparameter, you must includeio.coil-kt:coil-composein your Gradle dependencies. - Explicit imports : You must always import TV Material 3 classes explicitly (for example,
import androidx.tv.material3.Surface,import androidx.tv.material3.ListItem) instead of using wildcard imports (import androidx.tv.material3.*). - File naming conventions : You must name Composable screen files after the screen (for example, name
BrowseScreenasBrowseScreen.kt,PlaybackScreenasPlaybackScreen.kt, andAuthenticationScreenasAuthenticationScreen.kt). Don't use generic prefixes likeMain. - Overscan and bezels : You must apply horizontal padding (for example,
horizontal = 48.dpor32.dp,vertical = 24.dp) to root containers, carousels, and top bars to prevent clipping. - Reading width constrainment : You must constrain reading width using
Modifier.widthIn(max = 600.dp)on text columns for long-form text. - Media3 Compose dependencies : Include
androidx.media3:media3-ui-composeinapp/build.gradlewhen modernizing media playback screens. - Prohibition of legacy AndroidView wrappers : Don't use legacy
AndroidViewwrappers to embed View-based components into Jetpack Compose screens. All migrated screens must use Compose components or Media3 Compose surfaces (PlayerSurface).
D-pad focus handling and navigation
Jetpack Compose for TV (androidx.tv.material3) requires explicit focus
management, as components don't receive initial focus automatically and
navigation uses 2D spatial coordinates. To configure TV D-pad navigation, follow
instructions in TV Navigation guide.
Initial focus
You must assign initial focus to the primary interactive element on every screen
(such as the first action button, card, or ListItem) using FocusRequester
when entering a screen. Define val focusRequester = remember { FocusRequester() }, attach Modifier.focusRequester(focusRequester) to the primary element, and
request focus inside LaunchedEffect(Unit) { focusRequester.requestFocus() }:
val focusRequester = remember { FocusRequester() }
val focusManager = LocalFocusManager.current
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
<br />
*Note: For screens with dynamic state or pagers (like OnboardingScreen using
HorizontalPager), you must pass
Câu hỏi thường gặp
Nó có sao chép chính xác các bố cục Leanback cũ không?
Không. Nó ưu tiên các bố cục tùy chỉnh, mang tính điện ảnh hơn là sao chép trực tiếp từng khuôn mẫu cũ.
Giao diện 10-foot nghĩa là gì?
Đó là cách thiết kế cho TV được xem từ khoảng 3 mét, với chữ lớn và điều hướng đơn giản.
Nó dùng những thư viện nào?
Nó dùng các thư viện androidx.tv của Jetpack Compose cho TV.
Chi tiết
Mô tả gốc của tác giả
Provides instructions and architectural patterns for migrating Android TV applications from legacy Leanback UI Toolkit, Android Views, or Support Fragments to Jetpack Compose for TV (androidx.tv). Use this skill for Leanback to Compose migrations, including browse screen, settings screen, authentication screen, login screen, or video playback screen migrations, or when replacing BrowseSupportFragment, LeanbackSettingsFragment, PreferenceFragment, BaseLeanbackPreferenceFragmentCompat, VideoSupportFragment, GuidedStepSupportFragment, SearchSupportFragment, VerticalGridSupportFragment, Presenter,
repo: android/skills
Độ phổ biến
- Sao GitHub
- 10k
- Vị trí xếp hạng
- #11938
- Giấy phép
- Apache-2.0
- Cập nhật
- 29/10/2026
Bình luận
- …
Thêm skill từ kho mã này
agp-9-upgrade
10kGiúp agent của bạn nâng cấp ứng dụng Android lên Android Gradle Plugin 9 và xử lý các thay đổi gây lỗi. Không dành cho dự án đa nền tảng.
camerax
10kGiúp agent của bạn xây dựng các tính năng camera Android bằng CameraX, gồm quay video, điều khiển phần cứng, ML Kit và hiệu ứng Media3.
android-for-cars-parked-apps
10kĐiều chỉnh một ứng dụng video, trò chơi hoặc trình duyệt Android để chạy như ứng dụng khi xe đỗ trên Android Auto và Android Automotive.
appfunctions
10kTìm các luồng công việc chính trong ứng dụng Android và công khai chúng dưới dạng AppFunctions để agent AI và lệnh giọng nói có thể chạy.
Skill tương tự
android-clean-architecture
280kGiúp agent của bạn tổ chức dự án Android hiệu quả, cấu trúc code để việc bảo trì và phát triển tính năng mới dễ dàng hơn.
compose-multiplatform-patterns
280kGiúp agent của bạn dùng các mẫu Compose Multiplatform và Jetpack Compose trong dự án KMP, gồm trạng thái, điều hướng, giao diện và hiệu năng.
dart-flutter-patterns
280kGiúp agent của bạn viết code cho ứng dụng Dart và Flutter. Agent dùng các mẫu hiện đại để tạo ứng dụng vững chắc và dễ quản lý.