Câu Hỏi Phỏng Vấn Jetpack Compose
Jetpack Compose là yêu cầu bắt buộc cho vị trí Android developer mới tại Việt Nam 2026. Phỏng vấn Compose tập trung vào recomposition, state management, và side effects. Dưới đây là 10 câu hỏi thường gặp nhất.
10 câu hỏi2 dễ / 5 trung bình / 3 khó
Danh Sách Câu Hỏi
Dễ Trung bình Khó
1Recomposition trong Compose là gì? Khi nào xảy ra?trung bình
Recomposition trong Compose là gì? Khi nào xảy ra?trung bình
Recomposition: Compose gọi lại composable function khi state đọc bởi function đó thay đổi. Smart recomposition chỉ chạy lại phần bị ảnh hưởng. Triggered bởi State, MutableState, StateFlow changes. Skipped nếu parameters stable và unchanged.
2remember và rememberSaveable khác nhau thế nào?dễ
remember và rememberSaveable khác nhau thế nào?dễ
remember: cache value qua recomposition, mất khi composable rời composition hoặc configuration change. rememberSaveable: survive configuration changes (rotation) bằng Bundle. Dùng remember cho computed values, rememberSaveable cho UI state (scroll, input).
3State hoisting pattern trong Compose?trung bình
State hoisting pattern trong Compose?trung bình
Di chuyển state lên parent composable, truyền value và onValueChange xuống child. Lợi ích: single source of truth, dễ test, reusable composable. Pattern: stateful parent holds state, stateless child renders. ViewModel giữ business state, composable giữ UI state.
4Side effects trong Compose: LaunchedEffect, DisposableEffect, SideEffect?khó
Side effects trong Compose: LaunchedEffect, DisposableEffect, SideEffect?khó
LaunchedEffect(key): coroutine scope, restart khi key thay đổi - cho async work. DisposableEffect(key): cleanup khi leave composition - cho listeners/callbacks. SideEffect: mỗi successful recomposition - cho non-compose code. rememberCoroutineScope: cho event handlers.
5CompositionLocal là gì? Khi nào nên dùng?khó
CompositionLocal là gì? Khi nào nên dùng?khó
Implicit data passing qua composition tree mà không cần parameter drilling. staticCompositionLocalOf cho giá trị ít thay đổi (theme). compositionLocalOf cho giá trị thay đổi thường xuyên. Ví dụ: LocalContext, LocalDensity. Tránh overuse - prefer explicit parameters.
6Làm thế nào để tối ưu performance trong Compose?khó
Làm thế nào để tối ưu performance trong Compose?khó
Stable classes (@Stable, @Immutable) để skip recomposition. derivedStateOf cho computed state. key() cho LazyColumn items. Tránh allocations trong composable body. Defer reads (lambda) thay vì eager. Layout Inspector Recomposition Counts để debug.
7Modifier trong Compose hoạt động thế nào?trung bình
Modifier trong Compose hoạt động thế nào?trung bình
Modifier chain xử lý từ trái sang phải. Order matters: padding trước background khác background trước padding. Mỗi modifier wrap layout node. Custom modifier: Modifier.composed hoặc Modifier.Node (performance tốt hơn). Reuse modifier instances khi có thể.
8Navigation trong Compose khác gì Navigation truyền thống?trung bình
Navigation trong Compose khác gì Navigation truyền thống?trung bình
Compose Navigation: NavHost + composable() destinations, type-safe arguments với serializable classes. Không dùng Fragment. Deep links qua NavDeepLink. Nested NavGraphs cho feature modules. Back stack management tương tự nhưng API khác.
9Interop giữa Compose và XML Views thế nào?dễ
Interop giữa Compose và XML Views thế nào?dễ
ComposeView: embed Compose trong XML layout. AndroidView: embed XML View trong Compose. Approach dần dần: thêm Compose vào Fragment/Activity hiện tại. setContent{} cho toàn Activity. Shared ViewModel cho state sharing giữa hai systems.
10Animation trong Compose có những API nào?trung bình
Animation trong Compose có những API nào?trung bình
animate*AsState: đơn giản nhất, animate single value. updateTransition: coordinate multiple animations. AnimatedVisibility: show/hide with animation. Crossfade: switch content. InfiniteTransition: repeat forever. AnimationSpec: tween, spring, keyframes cho timing.
Câu Hỏi Thường Gặp
Biết XML Views là lợi thế vì nhiều dự án cần migration. Tuy nhiên, dự án mới hoàn toàn có thể chỉ hỏi Compose. Senior thường được hỏi về interop strategy.
Hiện tại ít phỏng vấn hỏi CMP tại Việt Nam. Tuy nhiên, biết CMP là điểm cộng lớn, đặc biệt cho vị trí senior hoặc product company.
Chuẩn bị phỏng vấn tốt hơn với bài tập thực hành
Xem Mobile Action ProHoặc xem Lộ Trình Android Developer 2026