Jetpack Compose 教學上課講義【從零開始學 Jetpack Compose 程式設計】Slot API 槽位佈局方式
【從零開始學 Jetpack Compose 程式設計】
線上教學課程目錄: https://bit.ly/3JF4SFA
Youtube 課程播放清單:https://bit.ly/3tFjRbx
Udemy 線上課程:https://bit.ly/3MbVnhO
【從零開始學 Jetpack Compose 程式設計】
線上教學課程目錄: https://bit.ly/3JF4SFA
Youtube 課程播放清單:https://bit.ly/3tFjRbx
Udemy 線上課程:https://bit.ly/3MbVnhO
Slot API
名詞圖像記憶解釋 Slot 概念
Slot 範例
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Demo(topContent = { View1() }, midContent = { View2() }, bottomContent = { View3() })
}
}
}
@Composable
fun Demo(
topContent: @Composable () -> Unit,
midContent: @Composable () -> Unit,
bottomContent: @Composable () -> Unit
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
topContent()
midContent()
bottomContent()
}
}
@Composable
fun View1() {
Text("上層內容")
}
@Composable
fun View2() {
Text("中層內容")
}
@Composable
fun View3() {
Text("底層內容")
}