RecyclerView의 레이아웃 관리자를 기반으로 필요한 지연 목록 컴포저블의 유형을 결정합니다 (아래 표 참고). 선택한 컴포저블은 이전 단계에서 추가한 ComposeView의 최상위 컴포저블이 됩니다.
LayoutManager
컴포저블
LinearLayoutManager
LazyColumn 또는 LazyRow
GridLayoutManager
LazyVerticalGrid 또는 LazyHorizontalGrid
StaggeredGridLayoutManager
LazyVerticalStaggeredGrid 또는 LazyHorizontalStaggeredGrid
// recyclerView.layoutManager = LinearLayoutManager(context)composeView.setContent{LazyColumn(Modifier.fillMaxSize()){// We use a LazyColumn since the layout manager of the RecyclerView is a vertical LinearLayoutManager}}
RecyclerView.Adapter 구현에서 각 뷰 유형에 상응하는 컴포저블을 만듭니다. 각 뷰 유형은 일반적으로 ViewHolder 하위 클래스에 매핑되지만 항상 그런 것은 아닙니다. 이러한 컴포저블은 목록에 있는 다양한 유형의 요소의 UI 표현으로 사용됩니다.
@ComposablefunListItem(data:MyData,modifier:Modifier=Modifier){Row(modifier.fillMaxWidth()){Text(text=data.name)// … other composables required for displaying `data`}}
RecyclerView.Adapter의 onCreateViewHolder() 및 onBindViewHolder() 메서드의 로직은 이러한 컴포저블과 컴포저블에 제공하는 상태로 대체됩니다. Compose에서는 항목의 컴포저블을 만드는 것과 데이터를 바인딩하는 것이 분리되어 있지 않습니다. 이러한 개념이 통합되어 있습니다.
지연 목록의 content 슬롯 (후행 람다 매개변수) 내에서 items() 함수 (또는 이에 상응하는 오버로드)를 사용하여 목록의 데이터를 반복합니다. itemContent 람다에서 데이터에 적합한 컴포저블 항목을 호출합니다.
어댑터가 변경될 때 항목의 모양을 애니메이션으로 표시하도록 RecyclerView에 ItemAnimator를 설정할 수 있습니다. 기본적으로 RecyclerView는 삭제, 추가, 이동 이벤트에 관한 기본 애니메이션을 제공하는 DefaultItemAnimator를 사용합니다.
지연 목록에는 animateItemPlacement 수정자를 통해 유사한 개념이 있습니다.
자세한 내용은 항목 애니메이션을 참고하세요.
추가 리소스
RecyclerView를 Compose로 이전하는 방법에 관한 자세한 내용은 다음 리소스를 참고하세요.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-22(UTC)
[[["이해하기 쉬움","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-22(UTC)"],[],[],null,["[`RecyclerView`](/develop/ui/views/layout/recyclerview) is a View component that makes it easy to efficiently display\nlarge sets of data. Instead of creating views for each item in the data set,\n`RecyclerView` improves the performance of your app by keeping a small pool of\nviews and recycling through them as you scroll through those items.\n\nIn Compose, you can use [Lazy lists](/develop/ui/compose/lists#lazy) to accomplish the same thing. This page\ndescribes how you can migrate your `RecyclerView` implementation to use Lazy lists\nin Compose.\n\nMigration steps\n\nTo migrate your `RecyclerView` implementation to Compose, follow these steps:\n\n1. Comment out or remove the `RecyclerView` from your UI hierarchy and add a\n `ComposeView` to replace it if none is present in the hierarchy yet. This\n is the container for the Lazy list that you'll add:\n\n \u003cFrameLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\u003e\n\n \u003c!-- \u003candroidx.recyclerview.widget.RecyclerView--\u003e\n \u003c!-- android:id=\"@+id/recycler_view\"--\u003e\n \u003c!-- android:layout_width=\"match_parent\"--\u003e\n \u003c!-- android:layout_height=\"match_parent /\u003e\"--\u003e\n\n \u003candroidx.compose.ui.platform.ComposeView\n android:id=\"@+id/compose_view\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\" /\u003e\n\n \u003c/FrameLayout\u003e\n\n2. Determine what type of Lazy list composable you need based on your\n `RecyclerView`'s layout manager (see table below). The composable you select\n will be the top-level composable of the `ComposeView` you added in the\n previous step.\n\n | `LayoutManager` | Composable |\n |------------------------------|--------------------------------------------------------------|\n | `LinearLayoutManager` | `LazyColumn` or `LazyRow` |\n | `GridLayoutManager` | `LazyVerticalGrid` or `LazyHorizontalGrid` |\n | `StaggeredGridLayoutManager` | `LazyVerticalStaggeredGrid` or `LazyHorizontalStaggeredGrid` |\n\n\n ```kotlin\n // recyclerView.layoutManager = LinearLayoutManager(context)\n composeView.setContent {\n LazyColumn(Modifier.fillMaxSize()) {\n // We use a LazyColumn since the layout manager of the RecyclerView is a vertical LinearLayoutManager\n }\n }https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/interop/MigrationCommonScenariosSnippets.kt#L79-L84\n ```\n\n \u003cbr /\u003e\n\n3. Create a corresponding composable for each view type in your\n `RecyclerView.Adapter` implementation. Each view type typically maps to a\n `ViewHolder` subclass, though this may not always be the case. These\n composables will be used as the UI representation for different types of\n elements in your list:\n\n\n ```kotlin\n @Composable\n fun ListItem(data: MyData, modifier: Modifier = Modifier) {\n Row(modifier.fillMaxWidth()) {\n Text(text = data.name)\n // ... other composables required for displaying `data`\n }\n }https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/interop/MigrationCommonScenariosSnippets.kt#L124-L130\n ```\n\n \u003cbr /\u003e\n\n The logic in your `RecyclerView.Adapter`'s `onCreateViewHolder()` and\n `onBindViewHolder()` methods will be replaced by these composables and the\n state that you provide them with. In Compose, there is no separation between\n creating a composable for an item and binding data into it---these concepts are\n coalesced.\n4. Within the `content` slot of the Lazy list (the trailing lambda parameter),\n use the `items()` function (or an equivalent overload) to iterate through the\n data for your list. In the `itemContent` lambda, invoke the appropriate\n composable item for your data:\n\n\n ```kotlin\n val data = listOf\u003cMyData\u003e(/* ... */)\n composeView.setContent {\n LazyColumn(Modifier.fillMaxSize()) {\n items(data) {\n ListItem(it)\n }\n }\n }https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/interop/MigrationCommonScenariosSnippets.kt#L90-L97\n ```\n\n \u003cbr /\u003e\n\n| **Tip:** Provide additional parameters to `items()` to optimize your list: use the `key` parameter to provide a unique key for the underlying data so that scroll position will be maintained when items change, or use the `contentType` parameter to specify a content type for the underlying data (this is a similar concept to `RecyclerView`'s view types) so you can reuse item compositions more efficiently.\n\nCommon use cases\n\nItem decorations\n\n`RecyclerView` has the concept of an `ItemDecoration`, which you can use to add a\nspecial drawing for items in the list. For example, you can add an\n`ItemDecoration` to add dividers between items:\n\n\n```kotlin\nval itemDecoration = DividerItemDecoration(recyclerView.context, LinearLayoutManager.VERTICAL)\nrecyclerView.addItemDecoration(itemDecoration)https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/interop/MigrationCommonScenariosSnippets.kt#L103-L104\n```\n\n\u003cbr /\u003e\n\nCompose does not have an equivalent concept of item decorations. Instead, you\ncan add any UI decorations in the list directly in the composition. For example,\nto add dividers to the list, you can use the `Divider` composable after each\nitem:\n\n\n```kotlin\nLazyColumn(Modifier.fillMaxSize()) {\n itemsIndexed(data) { index, d -\u003e\n ListItem(d)\n if (index != data.size - 1) {\n HorizontalDivider()\n }\n }\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/interop/MigrationCommonScenariosSnippets.kt#L111-L118\n```\n\n\u003cbr /\u003e\n\nItem animations\n\nAn `ItemAnimator` can be set on a `RecyclerView` to animate the appearance of\nitems as changes are made to the adapter. By default, `RecyclerView` uses\n[`DefaultItemAnimator`](/reference/androidx/recyclerview/widget/DefaultItemAnimator) which provides basic animations on remove, add, and\nmove events.\n\nLazy lists have a similar concept through the `animateItemPlacement` modifier.\nSee [Item animations](/develop/ui/compose/lists#item-animations) to learn more.\n\nAdditional resources\n\nFor more information about migrating a `RecyclerView` to Compose, see the\nfollowing resources:\n\n- [Lists and Grids](/develop/ui/compose/lists#item-animations): Documentation for how to implement lists and grids in Compose.\n- [Jetpack Compose Interop: Using Compose in a RecyclerView](https://medium.com/androiddevelopers/jetpack-compose-interop-using-compose-in-a-recyclerview-569c7ec7a583): Blog post for efficiently using Compose within a `RecyclerView`.\n\nRecommended for you\n\n- Note: link text is displayed when JavaScript is off\n- [Lists and grids](/develop/ui/compose/lists)\n- [Migrate `CoordinatorLayout` to Compose](/develop/ui/compose/migrate/migration-scenarios/coordinator-layout)\n- [Other considerations](/develop/ui/compose/migrate/other-considerations)"]]