[{"data":1,"prerenderedAt":232},["ShallowReactive",2],{"public-settings":3,"footer-custom-pages":18,"post-compose-first-migrating-legacy-xml-recyclerview":31,"article-code-ktrh2c":231},{"site_title":4,"tagline":5,"site_url":6,"footer_text":5,"social_twitter":7,"social_github":7,"social_youtube":7,"social_linkedin":7,"social_mastodon":7,"og_image":8,"comments_enabled":9,"ads_mode":10,"ads_publisher_id":11,"ads_adtest":12,"ads_in_article_enabled":9,"ads_in_article_slot":13,"ads_in_article_paragraph":14,"ads_end_of_post_enabled":9,"ads_end_of_post_slot":13,"ads_feed_enabled":9,"ads_feed_slot":13,"ads_feed_every":15,"ads_sidebar_enabled":9,"ads_sidebar_slot":13,"ads_consent_enabled":9,"clarity_enabled":12,"clarity_project_id":16,"seo_enabled":9,"llms_enabled":9,"verification_google":7,"verification_bing":7,"seo_home_title":7,"seo_description":7,"indexnow_key":7,"performance_lcp_preload":9,"pwa_enabled":9,"bookmarks_enabled":9,"comments_moderation":9,"home_carousel_featured":9,"home_carousel_latest":9,"home_carousel_latest_mode":17,"home_carousel_series":9,"home_carousel_topics":9},"Android Learner","Practical Android development, explained clearly.","https:\u002F\u002Fwww.androidlearner.com","","\u002Fmedia\u002Fseed\u002Fcover-llm.webp","1","live","ca-pub-3394535770235553","0","9901451769","2","3","jmrmm96ef6","latest",[19,26],{"id":20,"title":21,"slug":22,"show_in_footer":23,"sort_order":24,"updated_at":25},1,"Terms & Conditions","terms",true,10,"2026-11-28 13:13:48",{"id":27,"title":28,"slug":29,"show_in_footer":23,"sort_order":30,"updated_at":25},2,"Privacy Policy","privacy",20,{"post":32,"comments":230},{"id":33,"title":34,"slug":35,"path":36,"excerpt":37,"cover_image":38,"cover_media_id":39,"status":40,"publish_at":41,"reading_time":27,"seo_title":42,"seo_description":43,"og_image":38,"canonical_url":44,"noindex":45,"featured":45,"faq":46,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":54,"series":53,"tags":58,"author":77,"created_at":80,"updated_at":41,"body_md":81,"body_html":82,"related":83},24,"Google's \"Compose First\" Era: Migrating Legacy XML & RecyclerView Screens","compose-first-migrating-legacy-xml-recyclerview","\u002Fposts\u002Fcompose-first-migrating-legacy-xml-recyclerview","With android.widget Views, Fragments, and XML layout editors officially in maintenance mode, here is a practical, incremental playbook for migrating to Jetpack Compose.","\u002Fmedia\u002F2026\u002F11\u002F5f47e539df8d96b9.webp",66,"published","2026-11-28 10:14:54","Compose First Migration Guide: XML & RecyclerView to Compose","Step-by-step guide to migrating legacy Android XML layouts, Fragments, and RecyclerView adapters to Jetpack Compose without rewriting your entire app at once.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fcompose-first-migrating-legacy-xml-recyclerview\u002F",false,[47,50],{"question":48,"answer":49},"Do I have to rewrite my entire app to adopt Compose First?","No. You can embed Compose inside existing XML layouts with ComposeView, replace RecyclerView item types incrementally, and migrate Fragment navigation screen by screen.",{"question":51,"answer":52},"Are XML Views being removed from Android?","No, existing View APIs remain in the Android SDK for compatibility, but they are in maintenance mode—meaning critical bug fixes only, while all new UI capabilities ship in Jetpack Compose.",null,{"id":27,"name":55,"slug":56,"description":57},"Jetpack Compose","jetpack-compose","Modern Android UI.",[59,63,67,71,73],{"id":60,"name":61,"slug":62,"description":53},28,"Android","android",{"id":64,"name":65,"slug":66,"description":53},48,"Architecture","architecture",{"id":68,"name":69,"slug":70,"description":53},4,"Compose","compose",{"id":72,"name":55,"slug":56,"description":53},18,{"id":74,"name":75,"slug":76,"description":53},31,"Recycler View","recycler-view",{"id":20,"name":4,"username":78,"avatar":53,"profile_path":79},"superadmin","\u002Fu\u002Fsuperadmin","2026-11-28 10:11:53","Google has made **Jetpack Compose First** the official direction for Android UI. Legacy `android.widget` Views, Fragments, `RecyclerView`, and the XML layout editor are now in **maintenance mode**—receiving critical fixes without new features.\n\nIf your codebase still has XML screens or complex `RecyclerView` adapters, you do not need a risky big-bang rewrite. Here is a proven, incremental migration path.\n\n## Step 1: Start Inside Existing Fragments with `ComposeView`\n\nInstead of converting an entire flow at once, replace the body of a Fragment with `ComposeView` while keeping your existing navigation and `ViewModel` intact.\n\n```kotlin\nclass ProfileFragment : Fragment() {\n    private val viewModel: ProfileViewModel by viewModels()\n\n    override fun onCreateView(\n        inflater: LayoutInflater,\n        container: ViewGroup?,\n        savedInstanceState: Bundle?\n    ): View = ComposeView(requireContext()).apply {\n        setViewCompositionStrategy(\n            ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed\n        )\n        setContent {\n            AppTheme {\n                val uiState by viewModel.uiState.collectAsStateWithLifecycle()\n                ProfileScreen(\n                    state = uiState,\n                    onEditClick = { viewModel.onEditProfile() }\n                )\n            }\n        }\n    }\n}\n```\n\nAlways set `DisposeOnViewTreeLifecycleDestroyed` in Fragments so the composition disposes cleanly when the Fragment's view is destroyed on the back stack.\n\n## Step 2: Replace `RecyclerView` with `LazyColumn`\n\nA typical `RecyclerView` requires an Adapter, ViewHolder, `DiffUtil.ItemCallback`, and multiple XML item files. In Compose, `LazyColumn` handles diffing via stable `key` lambdas in a fraction of the code:\n\n```kotlin\n@Composable\nfun ArticleFeed(\n    articles: List\u003CArticleUiModel>,\n    onArticleClick: (String) -> Unit,\n    modifier: Modifier = Modifier\n) {\n    LazyColumn(\n        modifier = modifier.fillMaxSize(),\n        contentPadding = PaddingValues(16.dp),\n        verticalArrangement = Arrangement.spacedBy(12.dp)\n    ) {\n        items(\n            items = articles,\n            key = { it.id },\n            contentType = { it.type }\n        ) { article ->\n            ArticleCard(\n                article = article,\n                onClick = { onArticleClick(article.id) }\n            )\n        }\n    }\n}\n```\n\nPassing both `key` and `contentType` ensures smooth scrolling performance and efficient item reuse—even for heterogeneous feeds.\n\n## Step 3: Bridge Custom Views Only When Needed\n\nFor specialized legacy views (like a custom chart or map view), wrap them with `AndroidView` rather than blocking your migration:\n\n```kotlin\n@Composable\nfun LegacyMapContainer(\n    lat: Double,\n    lng: Double,\n    modifier: Modifier = Modifier\n) {\n    AndroidView(\n        modifier = modifier,\n        factory = { context -> CustomMapView(context) },\n        update = { mapView -> mapView.centerOn(lat, lng) }\n    )\n}\n```\n\n## Migration Order That Works Best\n\n1. **New features**: Build 100% in Compose from day one.\n2. **Leaf screens &amp; dialogs**: Convert settings, detail pages, and bottom sheets first.\n3. **List-heavy screens**: Replace `RecyclerView` screens to immediately cut boilerplate.\n4. **Navigation shell**: Once most screens are Compose, move from Fragment transactions to Navigation 3 or Compose Navigation.\n\n","\u003Cp>Google has made \u003Cstrong>Jetpack Compose First\u003C\u002Fstrong> the official direction for Android UI. Legacy \u003Ccode>android.widget\u003C\u002Fcode> Views, Fragments, \u003Ccode>RecyclerView\u003C\u002Fcode>, and the XML layout editor are now in \u003Cstrong>maintenance mode\u003C\u002Fstrong>—receiving critical fixes without new features.\u003C\u002Fp>\n\u003Cp>If your codebase still has XML screens or complex \u003Ccode>RecyclerView\u003C\u002Fcode> adapters, you do not need a risky big-bang rewrite. Here is a proven, incremental migration path.\u003C\u002Fp>\n\u003Ch2 id=\"step-1-start-inside-existing-fragments-with-composeview\">Step 1: Start Inside Existing Fragments with \u003Ccode>ComposeView\u003C\u002Fcode>\u003C\u002Fh2>\n\u003Cp>Instead of converting an entire flow at once, replace the body of a Fragment with \u003Ccode>ComposeView\u003C\u002Fcode> while keeping your existing navigation and \u003Ccode>ViewModel\u003C\u002Fcode> intact.\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">class ProfileFragment : Fragment() {\n    private val viewModel: ProfileViewModel by viewModels()\n\n    override fun onCreateView(\n        inflater: LayoutInflater,\n        container: ViewGroup?,\n        savedInstanceState: Bundle?\n    ): View = ComposeView(requireContext()).apply {\n        setViewCompositionStrategy(\n            ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed\n        )\n        setContent {\n            AppTheme {\n                val uiState by viewModel.uiState.collectAsStateWithLifecycle()\n                ProfileScreen(\n                    state = uiState,\n                    onEditClick = { viewModel.onEditProfile() }\n                )\n            }\n        }\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Always set \u003Ccode>DisposeOnViewTreeLifecycleDestroyed\u003C\u002Fcode> in Fragments so the composition disposes cleanly when the Fragment's view is destroyed on the back stack.\u003C\u002Fp>\n\u003Ch2 id=\"step-2-replace-recyclerview-with-lazycolumn\">Step 2: Replace \u003Ccode>RecyclerView\u003C\u002Fcode> with \u003Ccode>LazyColumn\u003C\u002Fcode>\u003C\u002Fh2>\n\u003Cp>A typical \u003Ccode>RecyclerView\u003C\u002Fcode> requires an Adapter, ViewHolder, \u003Ccode>DiffUtil.ItemCallback\u003C\u002Fcode>, and multiple XML item files. In Compose, \u003Ccode>LazyColumn\u003C\u002Fcode> handles diffing via stable \u003Ccode>key\u003C\u002Fcode> lambdas in a fraction of the code:\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">@Composable\nfun ArticleFeed(\n    articles: List&lt;ArticleUiModel&gt;,\n    onArticleClick: (String) -&gt; Unit,\n    modifier: Modifier = Modifier\n) {\n    LazyColumn(\n        modifier = modifier.fillMaxSize(),\n        contentPadding = PaddingValues(16.dp),\n        verticalArrangement = Arrangement.spacedBy(12.dp)\n    ) {\n        items(\n            items = articles,\n            key = { it.id },\n            contentType = { it.type }\n        ) { article -&gt;\n            ArticleCard(\n                article = article,\n                onClick = { onArticleClick(article.id) }\n            )\n        }\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Passing both \u003Ccode>key\u003C\u002Fcode> and \u003Ccode>contentType\u003C\u002Fcode> ensures smooth scrolling performance and efficient item reuse—even for heterogeneous feeds.\u003C\u002Fp>\n\u003Ch2 id=\"step-3-bridge-custom-views-only-when-needed\">Step 3: Bridge Custom Views Only When Needed\u003C\u002Fh2>\n\u003Cp>For specialized legacy views (like a custom chart or map view), wrap them with \u003Ccode>AndroidView\u003C\u002Fcode> rather than blocking your migration:\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">@Composable\nfun LegacyMapContainer(\n    lat: Double,\n    lng: Double,\n    modifier: Modifier = Modifier\n) {\n    AndroidView(\n        modifier = modifier,\n        factory = { context -&gt; CustomMapView(context) },\n        update = { mapView -&gt; mapView.centerOn(lat, lng) }\n    )\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"migration-order-that-works-best\">Migration Order That Works Best\u003C\u002Fh2>\n\u003Col>\n\u003Cli>\u003Cstrong>New features\u003C\u002Fstrong>: Build 100% in Compose from day one.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Leaf screens &amp; dialogs\u003C\u002Fstrong>: Convert settings, detail pages, and bottom sheets first.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>List-heavy screens\u003C\u002Fstrong>: Replace \u003Ccode>RecyclerView\u003C\u002Fcode> screens to immediately cut boilerplate.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Navigation shell\u003C\u002Fstrong>: Once most screens are Compose, move from Fragment transactions to Navigation 3 or Compose Navigation.\u003C\u002Fli>\n\u003C\u002Fol>\n",[84,125,160,200],{"id":85,"title":86,"slug":87,"path":88,"excerpt":89,"cover_image":90,"cover_media_id":91,"status":40,"publish_at":92,"reading_time":27,"seo_title":93,"seo_description":94,"og_image":90,"canonical_url":95,"noindex":45,"featured":45,"faq":96,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":103,"series":53,"tags":107,"author":122,"created_at":123,"updated_at":124},23,"Android 17 AppFunctions & Android MCP: Exposing App Actions to Gemini","android-17-appfunctions-android-mcp-gemini","\u002Fposts\u002Fandroid-17-appfunctions-android-mcp-gemini","Android 17 expands AppFunctions so apps can expose structured actions to Gemini and Android MCP clients. Learn how to declare functions, validate inputs, and test locally.","\u002Fmedia\u002F2026\u002F11\u002F89e9aba2e88d1684.webp",65,"2026-11-28 15:45:00","Android 17 AppFunctions & Android MCP Guide","Learn how to expose structured in-app capabilities using Android 17 AppFunctions and Jetpack libraries for Gemini and Android MCP orchestration.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-17-appfunctions-android-mcp-gemini\u002F",[97,100],{"question":98,"answer":99},"Do AppFunctions replace deep links or App Actions?","No. Deep links still open specific screens from URLs or intents, while AppFunctions expose typed, callable capabilities that the system or an on-device assistant can invoke with structured parameters and receive a typed result.",{"question":101,"answer":102},"Can users or the OS restrict which AppFunctions run?","Yes. AppFunctions follow Android's permission and user-consent model, and sensitive actions should require explicit confirmation or foreground verification before mutating user data.",{"id":20,"name":104,"slug":105,"description":106},"On-device AI","on-device-ai","Running models on the phone, not the cloud.",[108,111,112,116,120],{"id":30,"name":109,"slug":110,"description":53},"AI Development","ai-development",{"id":60,"name":61,"slug":62,"description":53},{"id":113,"name":114,"slug":115,"description":53},35,"Android 17","android-17",{"id":117,"name":118,"slug":119,"description":53},3,"Gemini Nano","gemini-nano",{"id":121,"name":104,"slug":105,"description":53},51,{"id":20,"name":4,"username":78,"avatar":53,"profile_path":79},"2026-11-28 10:11:52","2026-11-28 10:15:23",{"id":126,"title":127,"slug":128,"path":129,"excerpt":130,"cover_image":131,"cover_media_id":132,"status":40,"publish_at":133,"reading_time":27,"seo_title":134,"seo_description":135,"og_image":131,"canonical_url":136,"noindex":45,"featured":45,"faq":137,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":144,"series":53,"tags":146,"author":157,"created_at":158,"updated_at":159},27,"Jetpack AppState & Snapshot State Architecture: Beyond UI State","jetpack-appstate-snapshot-state-architecture","\u002Fposts\u002Fjetpack-appstate-snapshot-state-architecture","Compose's snapshot state system isn't just for UI. Learn how Jetpack AppState and snapshot-backed stores synchronize reactive state across screens, services, and widgets.","\u002Fmedia\u002F2026\u002F11\u002F3a2381e9f25fce93.webp",69,"2026-11-28 15:43:00","Jetpack AppState & Snapshot State Architecture in Android","Use Compose's snapshot state system and Jetpack AppState patterns to manage reactive state cleanly across ViewModels, background workers, and widgets.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fjetpack-appstate-snapshot-state-architecture\u002F",[138,141],{"question":139,"answer":140},"How is snapshot state different from MutableStateFlow?","Snapshot state tracks fine-grained property reads automatically without explicit combine\u002Fmap operators, and supports atomic multi-property transactions via Snapshot.withMutableSnapshot.",{"question":142,"answer":143},"Can snapshot state be used outside @Composable functions?","Yes. Compose Runtime's snapshot system has no Android View or UI dependency and can run in ViewModels, repositories, or background workers using snapshotFlow.",{"id":68,"name":65,"slug":66,"description":145},"App architecture and data layers.",[147,148,149,152,153],{"id":60,"name":61,"slug":62,"description":53},{"id":64,"name":65,"slug":66,"description":53},{"id":33,"name":150,"slug":151,"description":53},"Jetpack","jetpack",{"id":72,"name":55,"slug":56,"description":53},{"id":154,"name":155,"slug":156,"description":53},5,"State hoisting","state-hoisting",{"id":20,"name":4,"username":78,"avatar":53,"profile_path":79},"2026-11-28 10:11:54","2026-11-28 10:14:38",{"id":161,"title":162,"slug":163,"path":164,"excerpt":165,"cover_image":166,"cover_media_id":167,"status":40,"publish_at":133,"reading_time":27,"seo_title":168,"seo_description":169,"og_image":166,"canonical_url":170,"noindex":45,"featured":45,"faq":171,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":178,"series":53,"tags":182,"author":198,"created_at":158,"updated_at":199},26,"Kotlin Multiplatform (KMP) & Compose Multiplatform in 2026: Sharing Logic Without Regrets","kotlin-multiplatform-compose-multiplatform-2026","\u002Fposts\u002Fkotlin-multiplatform-compose-multiplatform-2026","A practical 2026 guide to structuring Kotlin Multiplatform modules, sharing Room\u002FKtor\u002FCoroutines across Android and iOS, and deciding when to use Compose Multiplatform.","\u002Fmedia\u002F2026\u002F11\u002Fc1c54b28d99ca23d.webp",68,"Kotlin Multiplatform & Compose Multiplatform Guide (2026)","How to structure Kotlin Multiplatform (KMP) projects in 2026 with shared Room, Ktor, and Compose Multiplatform without sacrificing native platform quality.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fkotlin-multiplatform-compose-multiplatform-2026\u002F",[172,175],{"question":173,"answer":174},"Should we share UI with Compose Multiplatform or keep SwiftUI on iOS?","Share business logic, networking, and local storage first. Adopt Compose Multiplatform for UI when your team wants unified feature velocity and consistent design, or keep SwiftUI for iOS-specific system integrations.",{"question":176,"answer":177},"Does Room work on iOS in Kotlin Multiplatform?","Yes. Official Room KMP support lets you share @Entity, @Dao, and @Database definitions across Android, iOS, and Desktop using SQLite drivers.",{"id":117,"name":179,"slug":180,"description":181},"Kotlin","kotlin","Language, coroutines, and Flow.",[183,184,188,192,194],{"id":68,"name":69,"slug":70,"description":53},{"id":185,"name":186,"slug":187,"description":53},6,"Coroutines","coroutines",{"id":189,"name":190,"slug":191,"description":53},22,"Cross-Platform","cross-platform",{"id":193,"name":179,"slug":180,"description":53},52,{"id":195,"name":196,"slug":197,"description":53},8,"Room","room",{"id":20,"name":4,"username":78,"avatar":53,"profile_path":79},"2026-11-28 10:13:23",{"id":201,"title":202,"slug":203,"path":204,"excerpt":205,"cover_image":206,"cover_media_id":207,"status":40,"publish_at":208,"reading_time":27,"seo_title":209,"seo_description":210,"og_image":206,"canonical_url":211,"noindex":45,"featured":45,"faq":212,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":219,"series":53,"tags":220,"author":229,"created_at":80,"updated_at":208},25,"Android 17's Mandatory Adaptive-First & Large-Screen Resizability Rules","android-17-adaptive-first-large-screen-resizability","\u002Fposts\u002Fandroid-17-adaptive-first-large-screen-resizability","Android 17 enforces adaptive-first layouts and large-screen resizability. Here is how to audit orientation locks, adopt WindowSizeClass, and ship ListDetailPaneScaffold.","\u002Fmedia\u002F2026\u002F11\u002F2df599bf25a8e4e3.webp",67,"2026-11-28 10:15:06","Android 17 Adaptive-First & Resizability Requirements","Prepare your Android app for Android 17's mandatory large-screen resizability and adaptive-first layout rules using WindowSizeClass and Material 3 adaptive scaffolds.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-17-adaptive-first-large-screen-resizability\u002F",[213,216],{"question":214,"answer":215},"Can I still lock screenOrientation=portrait on tablets and foldables in Android 17?","Android 17 removes legacy opt-outs for resizability on large screens (smallest width >= 600dp), meaning the system ignores fixed portrait\u002Flandscape locks and non-resizable flags.",{"question":217,"answer":218},"What is the fastest way to make an existing Compose screen adaptive?","Read currentWindowAdaptiveInfo() from Material 3 Adaptive, avoid hardcoded dp widths, and use ListDetailPaneScaffold or SupportingPaneScaffold for two-pane tablet and desktop layouts.",{"id":68,"name":65,"slug":66,"description":145},[221,222,223,224,225],{"id":60,"name":61,"slug":62,"description":53},{"id":113,"name":114,"slug":115,"description":53},{"id":64,"name":65,"slug":66,"description":53},{"id":72,"name":55,"slug":56,"description":53},{"id":226,"name":227,"slug":228,"description":53},46,"Material 3","material-3",{"id":20,"name":4,"username":78,"avatar":53,"profile_path":79},[],"\u003Cp>Google has made \u003Cstrong>Jetpack Compose First\u003C\u002Fstrong> the official direction for Android UI. Legacy \u003Ccode>android.widget\u003C\u002Fcode> Views, Fragments, \u003Ccode>RecyclerView\u003C\u002Fcode>, and the XML layout editor are now in \u003Cstrong>maintenance mode\u003C\u002Fstrong>—receiving critical fixes without new features.\u003C\u002Fp>\n\u003Cp>If your codebase still has XML screens or complex \u003Ccode>RecyclerView\u003C\u002Fcode> adapters, you do not need a risky big-bang rewrite. Here is a proven, incremental migration path.\u003C\u002Fp>\n\u003Ch2 id=\"step-1-start-inside-existing-fragments-with-composeview\">Step 1: Start Inside Existing Fragments with \u003Ccode>ComposeView\u003C\u002Fcode>\u003C\u002Fh2>\n\u003Cp>Instead of converting an entire flow at once, replace the body of a Fragment with \u003Ccode>ComposeView\u003C\u002Fcode> while keeping your existing navigation and \u003Ccode>ViewModel\u003C\u002Fcode> intact.\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> ProfileFragment\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> : \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Fragment\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    private\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> viewModel: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">ProfileViewModel\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> by\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> viewModels\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    override\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> fun\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> onCreateView\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        inflater: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">LayoutInflater\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        container: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">ViewGroup\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">?,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        savedInstanceState: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Bundle\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">?\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    ): \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">View\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> ComposeView\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">requireContext\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()).\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">apply\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        setViewCompositionStrategy\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        )\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        setContent\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">            AppTheme\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">                val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> uiState \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">by\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> viewModel.uiState.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">collectAsStateWithLifecycle\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">                ProfileScreen\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                    state \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> uiState,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                    onEditClick \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> { viewModel.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">onEditProfile\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                )\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Cp>Always set \u003Ccode>DisposeOnViewTreeLifecycleDestroyed\u003C\u002Fcode> in Fragments so the composition disposes cleanly when the Fragment's view is destroyed on the back stack.\u003C\u002Fp>\n\u003Ch2 id=\"step-2-replace-recyclerview-with-lazycolumn\">Step 2: Replace \u003Ccode>RecyclerView\u003C\u002Fcode> with \u003Ccode>LazyColumn\u003C\u002Fcode>\u003C\u002Fh2>\n\u003Cp>A typical \u003Ccode>RecyclerView\u003C\u002Fcode> requires an Adapter, ViewHolder, \u003Ccode>DiffUtil.ItemCallback\u003C\u002Fcode>, and multiple XML item files. In Compose, \u003Ccode>LazyColumn\u003C\u002Fcode> handles diffing via stable \u003Ccode>key\u003C\u002Fcode> lambdas in a fraction of the code:\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">@Composable\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">fun\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> ArticleFeed\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    articles: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">List\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">ArticleUiModel\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">>,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    onArticleClick: (\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) -> \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Unit\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    modifier: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Modifier\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> Modifier\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    LazyColumn\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        modifier \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> modifier.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">fillMaxSize\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        contentPadding \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> PaddingValues\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">16\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">.dp),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        verticalArrangement \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> Arrangement.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">spacedBy\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">12\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">.dp)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    ) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">        items\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            items \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> articles,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            key \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> { it.id },\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            contentType \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> { it.type }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        ) { article \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">->\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">            ArticleCard\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                article \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> article,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                onClick \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> { \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">onArticleClick\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(article.id) }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            )\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Cp>Passing both \u003Ccode>key\u003C\u002Fcode> and \u003Ccode>contentType\u003C\u002Fcode> ensures smooth scrolling performance and efficient item reuse—even for heterogeneous feeds.\u003C\u002Fp>\n\u003Ch2 id=\"step-3-bridge-custom-views-only-when-needed\">Step 3: Bridge Custom Views Only When Needed\u003C\u002Fh2>\n\u003Cp>For specialized legacy views (like a custom chart or map view), wrap them with \u003Ccode>AndroidView\u003C\u002Fcode> rather than blocking your migration:\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">@Composable\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">fun\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> LegacyMapContainer\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    lat: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Double\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    lng: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Double\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    modifier: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Modifier\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> Modifier\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    AndroidView\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        modifier \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> modifier,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        factory \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> { context \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">->\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> CustomMapView\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(context) },\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        update \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> { mapView \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">->\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> mapView.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">centerOn\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(lat, lng) }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    )\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Ch2 id=\"migration-order-that-works-best\">Migration Order That Works Best\u003C\u002Fh2>\n\u003Col>\n\u003Cli>\u003Cstrong>New features\u003C\u002Fstrong>: Build 100% in Compose from day one.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Leaf screens &amp; dialogs\u003C\u002Fstrong>: Convert settings, detail pages, and bottom sheets first.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>List-heavy screens\u003C\u002Fstrong>: Replace \u003Ccode>RecyclerView\u003C\u002Fcode> screens to immediately cut boilerplate.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Navigation shell\u003C\u002Fstrong>: Once most screens are Compose, move from Fragment transactions to Navigation 3 or Compose Navigation.\u003C\u002Fli>\n\u003C\u002Fol>\n",1795877411956]