Column {
Text("Hello")
Row {
Text("Compose")
Text("World")
}
}
=> Column ์์ Text์ Row๊ฐ ์๊ณ , Row ์์๋ ๋ Text ๋ ๊ฐ๊ฐ ๋ค์ด๊ฐ๋ ๊ตฌ์กฐ
@Composable
fun DemoText() {
Text(text = "์๋
ํ์ธ์")
}
UI์์ ํ ์คํธ๋ฅผ ๋ณด์ฌ์ฃผ๋ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ํํ
text ํ๋ผ๋ฏธํฐ ์ธ์๋ style, color, fontSize ๋ฑ์ ์ค์ ๊ฐ๋ฅ
@Preview(showBackground = true)
@Composable
fun DemoTextPreview() {
DemoText()
}
-> showBackground = true ์ต์
์ ์ฃผ๋ฉด, ๋ฏธ๋ฆฌ๋ณด๊ธฐ ๋ฐฐ๊ฒฝ์ด ํฐ์์ผ๋ก ๋์์ ๋ณด๊ธฐ ์ข๋ค!
@Composable
fun DemoSlider() {
var sliderPosition by remember { mutableStateOf(0f) }
Column {
Text("Value: ${sliderPosition}")
Slider(
value = sliderPosition,
onValueChange = { sliderPosition = it },
valueRange = 0f..100f
)
}
}
@Composable
fun DemoScreen() {
Column(modifier = Modifier.padding(16.dp)) {
DemoText()
Spacer(modifier = Modifier.height(16.dp))
DemoSlider()
}
}
Spacer๋ ์์ ๊ฐ ๊ฐ๊ฒฉ์ ์ค ๋ ์ฌ์ฉ
Modifier.padding์ผ๋ก ์ ์ฒด ์ฌ๋ฐฑ๋ ์ค์ ๊ฐ๋ฅ
@Preview(showSystemUi = true)
@Composable
fun DemoScreenPreview() {
DemoScreen()
}
AVD๋ ๊ฐ์ ์๋๋ก์ด๋ ๊ธฐ๊ธฐ๋ก ์ค์ ์ค๋งํธํฐ ์์ด ์ฑ ์คํ ๊ฐ๋ฅ
์์น: Tools > Device Manager
๋๋ฐ์ด์ค ์ด๋ฆ, Android ๋ฒ์ , ํ๋ฉด ํฌ๊ธฐ ๋ฑ์ ์ค์ ํด ๊ฐ์ ๋๋ฐ์ด์ค ์์ฑ
AVD๋ฅผ ์คํํ๋ฉด ๋จ๋ ์ฐฝ์ด ์๋ฎฌ๋ ์ดํฐ
์๋ฎฌ๋ ์ดํฐ์์๋ ์ค์ ์ฑ์ฒ๋ผ ์กฐ์ ๊ฐ๋ฅ (ํด๋ฆญ, ์ ์ค์ฒ, ํ์ , GPS ๋ฑ)
์ค๋ฅธ์ชฝ ๋ฐ์์ ๋ค์ํ ์ค์ ๊ฐ๋ฅ (์นด๋ฉ๋ผ, ๋ฐฐํฐ๋ฆฌ, ์ผ์ ๋ฑ)
๊ธฐ๋ณธ ํ๋ฉด ๊ตฌ์ฑ
Project ํจ๋: ์ ์ฒด ํด๋ ๊ตฌ์กฐ
Editor: ์ฝ๋๋ฅผ ์์ฑํ๋ ๊ณต๊ฐ
Preview: Compose UI ๋ฏธ๋ฆฌ๋ณด๊ธฐ
Logcat: ์ฑ ์คํ ์ค ๋ฐ์ํ๋ ๋ก๊ทธ ์ถ๋ ฅ
Model - View - ViewModel ๊ตฌ์กฐ
UI์ ๋ก์ง์ ๋ถ๋ฆฌํด์ ์ ์ง๋ณด์์ ํ ์คํธ๊ฐ ์ฌ์์ง
View: ํ๋ฉด (Activity, Compose UI)
ViewModel: ์ํ์ UI ๋ก์ง
Model: ๋ฐ์ดํฐ, API, DB
LiveData: ๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐ์ดํฐ
ViewModel: ์๋ช ์ฃผ๊ธฐ๋ฅผ ๊ณ ๋ คํ ์ํ ์ ์ฅ
Navigation: ํ๋ฉด ๊ฐ ์ด๋ ์ฒ๋ฆฌ
Room: SQLite ๊ธฐ๋ฐ ๋ก์ปฌ DB