Jetpack Compose 是 Android 的现代 declarative UI toolkit — 使用 composable Kotlin 函数而不是 XML 布局来构建 UI。这是 Google 推荐的新 Android UI 开发方式,提供了一种反应式、简洁且更高效的界面构建方法。
Compose 是什么
JETPACK COMPOSE = a declarative UI toolkit (Kotlin code, no XML):
→ describe the UI as COMPOSABLE FUNCTIONS (annotated @Composable)
→ DECLARATIVE + REACTIVE — describe UI for a given state; it updates when state changes
→ Google's RECOMMENDED modern approach (similar philosophy to Flutter, React, SwiftUI)
一个 composable 函数
{
Column {
Text()
Button(onClick = { }) {
Text()
}
}
}
