[null,null,["最終更新日 2025-07-27 UTC。"],[],[],null,["# Leanback UI toolkit libraries\n\nBuild better with Compose \nCreate beautiful UIs with minimal code using Jetpack Compose for Android TV OS. \n[Compose for TV →](/training/tv/playback/compose) \n\nThe Leanback UI toolkit provides some TV-specific libraries exclusive to\napps developed for Android TV OS. These libraries include the following:\n\n- [Leanback](/training/tv/playback) library: provides UI templates that simplify creating Android TV apps.\n- [Leanback Preferences](/reference/androidx/leanback/preference/package-summary) library: provides preferences and settings screens that are consistent with the platform but can be themed to match your app.\n- [Leanback Paging](#leanback-paging-library) library: supports the AndroidX paging model for `ObjectAdapters`, which are commonly used with the Leanback templates.\n- [Leanback Tabs](#leanback-tabs-library) library: supports tabbed navigation on Android TV.\n\nLeanback paging library\n-----------------------\n\nPaging inside the Leanback UI toolkit works the same as the AndroidX\n[Paging 3](/topic/libraries/architecture/paging/v3-overview) library, which\nsimplifies adding paging to a\n[`RecyclerView.Adapter`](/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter).\nWith the Leanback Paging library, the adapter that is exposed is typically an\n[`ObjectAdapter`](/reference/kotlin/androidx/leanback/widget/ObjectAdapter)\ninstead, so the library adds paging support to `ObjectAdapter`.\n\nTo add a paging adapter to your app, first add the library dependency to your project: \n\n implementation \"androidx.leanback:leanback-paging:$version\"\n\nThen follow the\n[Paging 3 documentation](/topic/libraries/architecture/paging/v3-overview) using\n`androidx.leanback.paging.PagingDataAdapter` instead of\n`androidx.paging.PagingDataAdapter`. The only difference is that you're now able\nto pass in a [`Presenter`](/reference/kotlin/androidx/leanback/widget/Presenter)\nor\n[`PresenterSelector`](/reference/kotlin/androidx/leanback/widget/PresenterSelector).\nThis works anywhere you would ordinarily use an `ObjectAdapter`, such as in a\n[`ListRow`](/reference/kotlin/androidx/leanback/widget/ListRow): \n\n### Kotlin\n\n```kotlin\nval adapter: PagingDataAdapter\u003cMyItem\u003e = PagingDataAdapter(myPresenter,\n object : DiffUtil.ItemCallback\u003cMyItem\u003e() {\n override fun areItemsTheSame(\n oldItem: MyItem,\n newItem: MyItem\n ): Boolean {\n return oldItem.id === newItem.id\n }\n\n override fun areContentsTheSame(\n oldItem: MyItem,\n newItem: MyItem\n ): Boolean {\n return oldItem == newItem\n }\n })\n\nval header = HeaderItem(headerTitle)\nval row = ListRow(header, adapter)\n```\n\n### Java\n\n```java\nPagingDataAdapter\u003cMyItem\u003e adapter = new PagingDataAdapter(myPresenter, new DiffUtil.ItemCallback\u003cMyItem\u003e() {\n @Override\n public boolean areItemsTheSame(@NonNull MyItem oldItem, @NonNull MyItem newItem) {\n return oldItem.getId().equals(newItem.getId());\n }\n\n @Override\n public boolean areContentsTheSame(@NonNull MyItem oldItem, @NonNull MyItem newItem) {\n return oldItem.equals(newItem);\n }\n});\n\nHeaderItem header = new HeaderItem(headerTitle);\nRow row = new ListRow(header, adapter);\n```\n\nLeanback Tabs library\n---------------------\n\nThe Leanback UI toolkit templates provide side navigation in the\n[browse screen](/training/tv/playback/browse). To add a row of tabs horizontally\nacross the top of the app, you can instead use Leanback Tabs instead.\n\nAdd the library dependency to your project: \n\n implementation \"androidx.leanback:leanback-tab:$version\"\n\nThen implement tabs using `LeanbackTabLayout` and `LeanbackViewPager` by\nfollowing the existing\n[ViewPager guide](/guide/navigation/navigation-swipe-view). Note that\n`LeanbackViewPager` is based on `ViewPager`, not `ViewPager2`.\n\nThe following is an example: \n\n### Kotlin\n\n```kotlin\nval leanbackTabLayout = findViewById\u003cLeanbackTabLayout\u003e(R.id.tab_layout)\nval leanbackViewPager = findViewById\u003cLeanbackViewPager\u003e(R.id.view_pager)\n\nleanbackViewPager.setAdapter(adapter)\nleanbackTabLayout.setupWithViewPager(leanbackViewPager)\n```\n\n### Java\n\n```java\nLeanbackTabLayout leanbackTabLayout = findViewById(R.id.tab_layout);\nLeanbackViewPager leanbackViewPager = findViewById(R.id.view_pager);\n\nleanbackViewPager.setAdapter(adapter);\nleanbackTabLayout.setupWithViewPager(leanbackViewPager);\n```\n\n### Limitations\n\nThe Leanback Tabs library has limitations in the themes it supports and how focus\nmovement is handled.\n\n#### Supported themes\n\nOnly themes that are derived from `Theme.AppCompat` are supported. `TabLayout`\ncontains a theme enforcement constraint, which prevents any nondescendant theme\nof `Theme.AppCompat` from being used. You can also use the bridge theme for the\nLeanback UI toolkit.\n\n#### Focus movement from tabs to top\n\nWhen the layout height is greater than the screen height and you press the D-pad\nup button, control moves back to the tab instead of staying inside the fragment\nand navigating to an item above it (see figure 1). To handle this issue, contents\ninside the fragment must override focus search; for example, use\n[`RowsSupportFragment`](/reference/androidx/leanback/app/RowsSupportFragment).\n[`BrowseSupportFragment`](/reference/androidx/leanback/app/BrowseSupportFragment)\ncannot be used inside a tab as it has an overridden focus search method which\nprevents the focus from moving back to the tab.\n**Figure 1.** D-pad up button moves focus to tab instead of preceding item."]]