CatalogBrowser는 미디어 카탈로그 브라우저를 구현하는 컴포저블 함수입니다. 이 함수는 다음 인수를 사용합니다.
추천 콘텐츠 목록입니다.
섹션 목록입니다.
수정자 객체입니다.
화면 전환을 트리거하는 콜백 함수입니다.
UI 요소 설정
TV용 Compose는 많은 수의 항목 (또는 길이를 알 수 없는 목록)을 표시하는 구성요소인 지연 목록을 제공합니다. LazyColumn를 호출하여 섹션을 세로로 배치합니다. LazyColumn는 항목 콘텐츠를 정의하는 DSL을 제공하는 LazyListScope.() -> Unit 블록을 제공합니다. 다음 예시에서는 각 섹션이 섹션 간 16dp 간격이 있는 세로 목록에 배치됩니다.
이 예에서 Section 컴포저블 함수는 섹션을 표시하는 방법을 정의합니다.
다음 함수에서 LazyRow은 제공된 DSL을 호출하여 LazyListScope.() -> Unit 블록이 있는 가로 목록을 정의하는 데 LazyColumn의 가로 버전이 유사하게 사용되는 방법을 보여줍니다.
Section 컴포저블에서는 Text 구성요소가 사용됩니다.
머티리얼 디자인에 정의된 텍스트와 기타 구성요소는 tv-material 라이브러리에서 제공됩니다 . MaterialTheme 객체를 참조하여 Material Design에 정의된 텍스트 스타일을 변경할 수 있습니다.
이 객체는 tv-material 라이브러리에서도 제공됩니다.
Card는 tv-material 라이브러리의 일부입니다.
MovieCard는 각 영화 데이터가 다음 스니펫으로 정의된 카탈로그에 렌더링되는 방식을 정의합니다.
앞서 설명한 예에서는 모든 영화가 동일하게 표시됩니다.
영역이 동일하며 시각적 차이가 없습니다.
Carousel를 사용하여 일부를 강조 표시할 수 있습니다.
캐러셀은 슬라이드, 페이드 또는 뷰로 이동할 수 있는 항목 집합에 정보를 표시합니다. 이 구성요소를 사용하여 새로 제공되는 영화나 TV 프로그램의 새 에피소드와 같은 추천 콘텐츠를 강조 표시합니다.
Carousel에서는 캐러셀에 포함된 항목 수와 각 항목을 그리는 방법을 최소한 지정해야 합니다. 첫 번째는 itemCount로 지정할 수 있습니다. 두 번째는 람다로 전달할 수 있습니다. 표시된 항목의 색인 번호가 람다에 제공됩니다. 주어진 색인 값으로 표시된 항목을 확인할 수 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-21(UTC)
[null,null,["최종 업데이트: 2025-08-21(UTC)"],[],[],null,["# Create a catalog browser\n\nA media app that runs on a TV needs to allow users to browse its content\nofferings, make a selection, and start playing content. The content browsing\nexperience for apps of this type should be simple, intuitive, and visually\npleasing and engaging.\n\nA media catalog browser tends to consist of several sections, and each section\nhas a list of media content. Examples of sections in a media catalog include:\nplaylists, featured content, recommended categories.\n**Figure 1.** Typical catalog screen. Users are able to browse video catalog data.\n\nUse the functions provided by Compose for TV to implement a user\ninterface for browsing music or videos from your app's media catalog.\n\nCreate a composable function for catalog\n----------------------------------------\n\nEverything appearing on a display is implemented as a composable function in\nCompose for TV. Start by defining a composable\nfunction for the media catalog browser: \n\n @Composable\n fun CatalogBrowser(\n featuredContentList: List\u003cMovie\u003e,\n sectionList: List\u003cSection\u003e,\n modifier: Modifier = Modifier,\n onItemSelected: (Movie) -\u003e Unit = {},\n ) {\n // ToDo: add implementation\n }\n\n`CatalogBrowser` is the composable function implementing your media catalog\nbrowser. The function takes the following arguments:\n\n- List of featured content.\n- List of sections.\n- A Modifier object.\n- A callback function, which triggers a screen transition.\n\nSet UI elements\n---------------\n\nCompose for TV offers lazy lists, a component to display a large\nnumber of items (or a list of an unknown length). Call\n[`LazyColumn`](/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyColumn(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,kotlin.Function1))\nto place sections vertically. `LazyColumn` provides a\n[`LazyListScope.() -\u003e Unit`](/reference/kotlin/androidx/compose/foundation/lazy/LazyListScope)\nblock, which offers a DSL to define item contents. In the following example,\neach section is placed in a vertical list with a 16 dp gap between sections: \n\n @Composable\n fun CatalogBrowser(\n featuredContentList: List\u003cMovie\u003e,\n sectionList: List\u003cSection\u003e,\n modifier: Modifier = Modifier,\n onItemSelected: (Movie) -\u003e Unit = {},\n ) {\n LazyColumn(\n modifier = modifier.fillMaxSize(),\n verticalArrangement = Arrangement.spacedBy(16.dp)\n ) {\n items(sectionList) { section -\u003e\n Section(section, onItemSelected = onItemSelected)\n }\n }\n }\n\nIn the example, `Section` composable function defines how to display sections.\nIn the following function, [`LazyRow`](/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyRow(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,kotlin.Function1)) demonstrates how this\nhorizontal version of [`LazyColumn`](/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyColumn(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,kotlin.Function1)) is similarly used to\ndefine a horizontal list with a `LazyListScope.() -\u003e Unit` block by calling\nthe provided DSL: \n\n @Composable\n fun Section(\n section: Section,\n modifier: Modifier = Modifier,\n onItemSelected: (Movie) -\u003e Unit = {},\n ) {\n Text(\n text = section.title,\n style = MaterialTheme.typography.headlineSmall,\n )\n LazyRow(\n modifier = modifier,\n horizontalArrangement = Arrangement.spacedBy(8.dp)\n ) {\n items(section.movieList){ movie -\u003e\n MovieCard(\n movie = movie,\n onClick = { onItemSelected(movie) }\n )\n }\n }\n }\n\nIn the `Section` composable, the [`Text`](/reference/kotlin/androidx/tv/material3/package-summary#Text(androidx.compose.ui.text.AnnotatedString,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextDecoration,androidx.compose.ui.text.style.TextAlign,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.collections.Map,kotlin.Function1,androidx.compose.ui.text.TextStyle)) component is used.\nText and other components\ndefined in Material Design are offered in the tv-material library . You can\nchange the texts' style as defined in Material Design by referring to the\n[`MaterialTheme`](/reference/kotlin/androidx/tv/material3/MaterialTheme) object.\nThis object is also provided by the tv-material library.\n[`Card`](/reference/kotlin/androidx/tv/material3/package-summary#Card(kotlin.Function0,androidx.compose.ui.Modifier,androidx.tv.material3.CardShape,androidx.tv.material3.CardColors,androidx.tv.material3.CardScale,androidx.tv.material3.CardBorder,androidx.tv.material3.CardGlow,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function1)) is part of the tv-material library.\n`MovieCard` defines how each movie data is rendered in the catalog defined\nas the following snippet: \n\n @Composable\n fun MovieCard(\n movie: Movie,\n modifier: Modifier = Modifier,\n onClick: () -\u003e Unit = {}\n ) {\n Card(modifier = modifier, onClick = onClick){\n AsyncImage(\n model = movie.thumbnailUrl,\n contentDescription = movie.title,\n )\n }\n }\n\n| **Note:** `AsyncImage` is a composable that loads an image from the internet. See [Loading Images](/develop/ui/compose/graphics/images/loading#internet-loading) for details.\n\nHighlight featured content\n--------------------------\n\nIn the example described earlier, all movies are displayed equally.\nThey have the same area, no visual difference between them.\nYou can highlight some of them with [`Carousel`](/reference/kotlin/androidx/tv/material3/package-summary#Carousel(kotlin.Int,androidx.compose.ui.Modifier,androidx.tv.material3.CarouselState,kotlin.Long,androidx.compose.animation.ContentTransform,androidx.compose.animation.ContentTransform,kotlin.Function1,kotlin.Function2)).\n\nCarousel displays the information in a set of items that can slide, fade, or\nmove into view. You use the component to highlight featured content, such as\nnewly available movies or new episodes of TV programs.\n\n[`Carousel`](/reference/kotlin/androidx/tv/material3/package-summary#Carousel(kotlin.Int,androidx.compose.ui.Modifier,androidx.tv.material3.CarouselState,kotlin.Long,androidx.compose.animation.ContentTransform,androidx.compose.animation.ContentTransform,kotlin.Function1,kotlin.Function2))\nexpects you to at least specify the number of items that Carousel has and how to\ndraw each item. The first one can be specified with `itemCount`. The second one\ncan be passed as a lambda. The index number of the displayed item is\ngiven to the lambda. You can determine the displayed item with the\ngiven index value: \n\n @Composable\n function FeaturedCarousel(\n featuredContentList: List\u003cMovie\u003e,\n modifier: Modifier = Modifier,\n ) {\n Carousel(\n itemCount = featuredContentList.size,\n modifier = modifier,\n ) { index -\u003e\n val content = featuredContentList[index]\n Box {\n AsyncImage(\n model = content.backgroundImageUrl,\n contentDescription = content.description,\n placeholder = painterResource(\n id = R.drawable.placeholder\n ),\n contentScale = ContentScale.Crop,\n modifier = Modifier.fillMaxSize()\n )\n Text(text = content.title)\n }\n }\n }\n\n`Carousel` can be an item of a lazy list, such as `TvLazyColumn`.\nThe following snippet shows `FeaturedCarousel` composable on top of the\nall `Section` composables: \n\n @Composable\n fun CatalogBrowser(\n featuredContentList: List\u003cMovie\u003e,\n sectionList: List\u003cSection\u003e,\n modifier: Modifier = Modifier,\n onItemSelected: (Movie) -\u003e Unit = {},\n ) {\n TvLazyColumn(\n modifier = modifier.fillMaxSize(),\n verticalArrangement = Arrangement.spacedBy(16.dp)\n ) {\n\n item {\n FeaturedCarousel(featuredContentList)\n }\n\n items(sectionList) { section -\u003e\n Section(section, onItemSelected = onItemSelected)\n }\n }\n }"]]