https://tourspace.tistory.com/403
🍎 Compose란?
→ 여러 함수들을 호출하여 데이터를 구조화된 UI로 만들수 있는 선언형 UI
🍎 Compose ui.theme 구성
(1) Color.kt = colors.xml
(2) Shape.kt = drawable xml의 <shape… 를 대체
val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)
(3) Typogtaphy.kt : 글자의 style 정의값
val Typhography = Typography(
body1 = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
)
(4) Theme.kt : 앱 테마
🍎 선언형 UI
만약 TextView에 배경색을 입히고 싶다면?
import androidx.compose.ui.graphics.Color
@Composable
fun Greeting(name: String) {
Surface(color = Color.Yellow) {
Text(text = "Hello $name!")
}
}
🍎 Compose의 State
recomposing : 데이터 상태 변화에 따라 자동 호출되어 UI가 다시 그려지는 작업