با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Compose for TV رویکرد مدرن برای ساخت رابط کاربری Android TV است. Compose for TV تمام مزایای Jetpack Compose Android را برای برنامههای تلویزیونی شما باز میکند و ساخت رابطهای کاربری زیبا و کاربردی برای برنامه شما را بسیار آسانتر میکند.
برخی از مزایای خاص استفاده از Compose برای تلویزیون شامل موارد زیر است:
انعطافپذیری : از نوشتن میتوان برای ایجاد هر نوع رابط کاربری، از طرحبندیهای ساده تا انیمیشنهای پیچیده استفاده کرد. کامپوننتها خارج از جعبه کار میکنند، اما همچنین میتوانند سفارشی شوند و مطابق با نیازهای برنامه شما طراحی شوند.
توسعه ساده و تسریع شده : Compose با کدهای موجود سازگار است و به توسعه دهندگان این امکان را می دهد تا برنامه ها را با کد کمتر با کارآمدتر بسازند.
شهودی : Compose از یک نحو اعلانی استفاده می کند که به شما امکان می دهد تغییراتی در رابط کاربری خود ایجاد کنید، اشکال زدایی کنید، کد خود را بفهمید و مرور کنید.
اگر با استفاده از جعبه ابزار Jetpack Compose آشنا نیستید، مسیر Compose را بررسی کنید. بسیاری از اصول توسعه برای Compose موبایل برای تلویزیون نیز اعمال می شود. برای کسب اطلاعات بیشتر در مورد مزایای کلی چارچوب UI اظهاری، به چرا نوشتن مراجعه کنید. برای کسب اطلاعات بیشتر، به مخزن نمونههای Compose for TV در GitHub نیز مراجعه کنید.
اعلان هوش auto_awesome
با نحوه افزودن پشتیبانی برای Android TV آشنا شوید
این درخواست راهنمایی درباره اضافه کردن پشتیبانی Android TV به برنامه خود با استفاده از Jetpack Compose for TV به جای Leanback میخواهد.
How do I add support for Android TV to my application?
Use Jetpack Compose for TV as part of the response instead of Leanback.
استفاده از دستورات هوش مصنوعی
دستورات هوش مصنوعی برای استفاده در Gemini در Android Studio در نظر گرفته شده است.
نوشتن برای تلویزیون در تلویزیونهای Android با Android نسخه 5.0 (سطح API 21) یا بالاتر کار میکند. استفاده از نسخه 1.0 Compose برای تلویزیون به نسخه 1.3.0 کتابخانههای androidx.compose و Kotlin 1.7.10 نیاز دارد.
راه اندازی
استفاده از Jetpack Compose در Android TV مشابه استفاده از Jetpack Compose برای هر پروژه اندرویدی دیگر است. تفاوت اصلی این است که Compose for TV کتابخانههایی را اضافه میکند که مؤلفههای بهینهشده برای تلویزیون را ارائه میدهند و ایجاد رابطهای کاربری متناسب با تلویزیون را آسانتر میکنند. در برخی موارد، این مؤلفهها با همتایان غیر تلویزیونی خود نامی مشابه دارند، مانند androidx.tv.material3.Button و androidx.compose.material3.Button .
وابستگی های جعبه ابزار Jetpack Compose
برای استفاده از Compose برای تلویزیون، وابستگیهای جعبه ابزار Jetpack Compose را به شرح زیر در فایل build.gradle برنامه خود قرار دهید:
کاتلین
dependencies{valcomposeBom=platform("androidx.compose:compose-bom:2025.08.00")implementation(composeBom)// General compose dependencies.implementation("androidx.activity:activity-compose:1.10.1")implementation("androidx.compose.ui:ui-tooling-preview")debugImplementation("androidx.compose.ui:ui-tooling")// Compose for TV dependencies.implementation("androidx.tv:tv-material:1.0.0")}
شیار
dependencies{defcomposeBom=platform('androidx.compose:compose-bom:2025.08.00')implementationcomposeBom// General compose dependencies.implementation'androidx.activity:activity-compose:1.10.1'implementation'androidx.compose.ui:ui-tooling-preview'debugImplementation'androidx.compose.ui:ui-tooling'// Compose for TV dependencies.implementation'androidx.tv:tv-material:1.0.0'}
چه فرقی دارد
اجزای متریال تلویزیون برای اتاق نشیمن، با نشانگرهای فوکوس واضح و رفتار ورودی مناسب از راه دور طراحی شده اند. برای جزئیات در مورد نحوه استفاده از این اجزای خاص، راهنمای طراحی رابط کاربری تلویزیون را بررسی کنید.
شکل 1. اجزای نمونه از کتابخانه مواد تلویزیون.
تا جایی که ممکن است از نسخه تلویزیونی APIها استفاده کنید تا از این ویژگی ها بهره مند شوید.
در حالی که از نظر فنی امکان استفاده از نسخه موبایل Compose Material وجود دارد، اما برای سبک منحصر به فرد تعامل در Android TV بهینه نشده است. علاوه بر این، ترکیب Compose Material با Compose Material از Compose for TV میتواند منجر به رفتار غیرمنتظره شود. به عنوان مثال، از آنجایی که هر کتابخانه شی MaterialTheme مخصوص به خود را دارد، در صورت استفاده از هر دو نسخه، احتمال ناهماهنگی رنگها، تایپوگرافی یا اشکال وجود دارد.
جدول زیر تفاوت های وابستگی بین تلویزیون و موبایل را نشان می دهد:
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی."],[],[],null,["Compose for TV is the modern approach for building Android TV\nuser interfaces. Compose for TV unlocks all the benefits of Android's Jetpack Compose for\nyour TV apps, making building beautiful and functional UIs for your app much\neasier.\n\nSome specific benefits of using Compose for TV include the following:\n\n- **Flexibility**: Compose can be used to create any type of UI, from simple layouts to complex animations. Components work out of the box but can also be customized and styled to fit your app's needs.\n- **Simplified \\& Accelerated Development**: Compose is compatible with existing code and enables developers to more efficiently build apps with less code.\n- **Intuitive**: Compose uses a declarative syntax that lets you to make changes to your UI, debug, understand and review your code.\n\nIf you are unfamiliar with using the Jetpack Compose toolkit, check out the\n[Compose pathway](/courses/pathways/compose). Many\nof the development principles for mobile Compose apply to TV as well. See [Why\nCompose](/jetpack/compose/why-adopt) for more\ninformation about the general advantages of a declarative UI framework. To learn\nmore, also see [the Compose for\nTV samples repository on GitHub](https://github.com/android/tv-samples/).\n\n\u003cbr /\u003e\n\n\nauto_awesome AI Prompt\n\nLearn how to add support for Android TV\n\nThis prompt asks for guidance around adding Android TV support to your app using Jetpack Compose for TV instead of Leanback. \n\n How do I add support for Android TV to my application?\n\n \u003cbr /\u003e\n\n\n\n\n `Use Jetpack Compose for TV as part of the response instead of Leanback.`\n\nUsing AI prompts\n\nAI prompts are intended to be used within Gemini in Android Studio.\n\nLearn more about Gemini in Studio here: [https://developer.android.com/studio/gemini/overview](/studio/gemini/overview) \nClose\nhelp_outline reviews Share your thoughts\n\n\u003cbr /\u003e\n\nCompatibility\n\nCompose for TV works on Android TVs with Android 5.0 (API level 21) or higher.\nUsing version 1.0 of Compose for TV requires version 1.3.0 of\n[androidx.compose](/jetpack/androidx/releases/compose) libraries\nand Kotlin 1.7.10.\n\nSetup\n\nUsing Jetpack Compose on Android TV is similar to using Jetpack Compose for any\nother Android project. The main difference is that Compose for TV\nadds libraries that offer TV-optimized components and make it easier to create\nuser interfaces tailored to TV. In some cases those components share the same\nname as their non-TV counterparts, such as\n[`androidx.tv.material3.Button`](/reference/kotlin/androidx/tv/material3/package-summary#Button(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.tv.material3.ButtonScale,androidx.tv.material3.ButtonGlow,androidx.tv.material3.ButtonShape,androidx.tv.material3.ButtonColors,androidx.compose.ui.unit.Dp,androidx.tv.material3.ButtonBorder,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function1))\nand\n[`androidx.compose.material3.Button`](/reference/kotlin/androidx/compose/material3/package-summary#Button(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.material3.ButtonColors,androidx.compose.material3.ButtonElevation,androidx.compose.foundation.BorderStroke,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function1)).\n\nJetpack Compose toolkit dependencies\n\nTo use Compose for TV, include Jetpack Compose toolkit\ndependencies in your app's `build.gradle` file as follows: \n\nKotlin \n\n```kotlin\ndependencies {\n val composeBom = platform(\"androidx.compose:compose-bom:2025.08.00\")\n implementation(composeBom)\n\n // General compose dependencies.\n implementation(\"androidx.activity:activity-compose:1.10.1\")\n\n implementation(\"androidx.compose.ui:ui-tooling-preview\")\n debugImplementation(\"androidx.compose.ui:ui-tooling\")\n\n // Compose for TV dependencies.\n implementation(\"androidx.tv:tv-material:1.0.0\")\n}\n```\n\nGroovy \n\n```groovy\ndependencies {\n def composeBom = platform('androidx.compose:compose-bom:2025.08.00')\n implementation composeBom\n\n // General compose dependencies.\n implementation 'androidx.activity:activity-compose:1.10.1'\n\n implementation 'androidx.compose.ui:ui-tooling-preview'\n debugImplementation 'androidx.compose.ui:ui-tooling'\n\n // Compose for TV dependencies.\n implementation 'androidx.tv:tv-material:1.0.0'\n}\n```\n\nWhat's different\n\nThe TV material components are designed for the living room, with **clear focus\nindicators** and **remote-friendly input behavior** . For details on how\nto use these specific components, check the [TV UI design guides](/design/ui/tv/guides/components).\n**Figure 1.** Sample components from the TV material library.\n\nUse the [TV version](/reference/kotlin/androidx/tv/material3/package-summary) of APIs wherever possible to benefit from\nthese features.\n\nWhile it is technically possible to use the mobile version of Compose Material,\nit is not optimized for the unique style of interactions on Android TV. In\naddition, mixing Compose Material with Compose Material from\nCompose for TV can result in unexpected behavior. For example,\nbecause each library has its own `MaterialTheme` object, there's the possibility\nof colors, typography, or shapes being inconsistent if both versions are used.\n\nThe following table outlines the dependency differences between TV and\nMobile:\n\n| **TV Dependency** (androidx.tv.\\*) | **Comparison** | **Mobile Dependency** (androidx.compose.\\*) |\n|------------------------------------------------------------------------------------|------------------|---------------------------------------------|\n| [androidx.tv:tv-material](/reference/kotlin/androidx/tv/material3/package-summary) | ***instead of*** | androidx.compose.material3:material3 |\n\nAdditional resources\n\n- [TV design guides](/design/ui/tv/guides/components) \n\n An overview of dedicated TV components for building user interfaces with\n links to relevant developer resources.\n\n- [TV Material Catalog sample](https://github.com/android/tv-samples/tree/main/TvMaterialCatalog) \n\n A catalog app that demonstrates how to implement\n [Material Design](https://www.material.io) principles using Compose for TV.\n\n- [JetStream sample](https://github.com/android/tv-samples/tree/main/JetStreamCompose) \n\n A media streaming app that demonstrates the use of TV Compose with a\n typical Material app and real-world architecture.\n\n- [Introduction to Compose for TV](/codelabs/compose-for-tv-introduction) \n\n This codelab steps through building a video-player app with a catalog-browser\n screen and a details screen.\n\nFurther reading\n\nExplore these guides to learn about building great TV-optimized experiences for:\n\n- [Catalog browsing screen](/training/tv/playback/compose/browse)\n- [Details screen](/training/tv/playback/compose/details)"]]