Android Compose Advanced
Advanced Jetpack Compose: custom layouts, performance, animations, gestures, and testing
1How to create a Custom Layout in Compose?
How to create a Custom Layout in Compose?
답변
Use the Layout { measurables, constraints -> } function. It allows measuring children with measurables.forEach { it.measure(constraints) }, then placing them with layout(width, height) { placeables.forEach { it.place(x, y) } }.
2What is SubcomposeLayout?
What is SubcomposeLayout?
답변
SubcomposeLayout allows composing children dynamically based on constraints or measurements of other children. Useful for layouts where one element's size depends on another (e.g., measure header before composing body).
3What are the 3 phases of the Compose lifecycle?
What are the 3 phases of the Compose lifecycle?
답변
The 3 phases are: 1) Composition (UI tree creation, @Composable execution), 2) Layout (measurement and placement of elements), 3) Drawing (rendering to screen). Understanding these phases helps optimize performance.
What is derivedStateOf used for?
How to optimize recompositions in Compose?
+14 면접 질문