#1 ์ผ๊ด์ ๊ธ๊ผด ํ์
ํ๋ก์ ํธ ๋ด์์ ์ฐ์ธ ๊ธ์จ์ ํฌ๊ธฐ๊ฐ ์ค๊ตฌ๋๋ฐฉ์ด๋ผ๋ ๋ฌธ์ ์ ์ด ์๋ค. ํ์ฌ๋, fontSize ์์ฑ์ ์ง๋ ์ปดํฌ์ ๋ธ๋ณ๋ก ํฌ๊ธฐ๊ฐ์ ์ผ์ผํ ํ ๋นํด๋์๊ธฐ ๋๋ฌธ์ด๋ค. ์ด๋ฅผ ์ ์ฒด์ ์ผ๋ก ํต์ ํ ์ ์์ด์ผ ํ๋ค. ํฌ๊ธฐ ๋ฟ๋ง ์๋๋ผ, ๋ฒํผ์ ๋ค์ด๊ฐ๋ ์ฉ๋์ ๊ธ๊ผด์ ๋ณ๋๋ก ์ ์ธํด๋์๋ค๊ฐ ๋๊ณ ๋๊ณ ์ฐ๋ ๊ฒฝ์ฐ๋ ์์ผ๋ก ์๊ธธํ ๋ค.
#2 Typography
#2-1 ๋จธํฐ๋ฆฌ์ผ ๋์์ธ ๊ฐ์ด๋
Typography โ Material Design 3
Learn about Material Design typography. This guide covers everything from font styles and hierarchy to line height to create user-friendly text.
m3.material.io
๋จธํฐ๋ฆฌ์ผ ๋์์ธ ๊ฐ์ด๋์์๋ ์ผ๊ด์ ์ธ ๊ธ๊ผด์ ์ ๊ณตํ๋ค. ๊ฒ๋ค๊ฐ, ์๋๋ก์ด๋ ํ๋ก์ ํธ์ ๊ธฐ๋ณธ์ ์ผ๋ก ํตํฉ๋์ด ์๋ค. ๊ทธ๋์ ๋ณ๋์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ค์ด๋ก๋ ์์ ์์ด ์ฆ์ ์ฌ์ฉํ ์ ์๋ค. ์๋๋ ๊ทธ ์์ ์ฝ๋๋ค.
#2-2 Typography ํ์ฉ ์ 1
Text(
text = "Sample Top Bar Text",
style = MaterialTheme.typography.headlineLarge
)
style ์์ฑ์ MaterialTheme.typography.headlineLarge (์ดํ headlineLarge)๋ผ๋ ๊ธ๊ผด์ ๋์ ํ๋ค. ์ด ์์ ์ ๋ง์น HTML ํ๊ทธ์ ๊ฐํ๋ css ์คํ์ผ๊ณผ ๋น์ทํ๋ค. ์ด์ ๋ถํฐ, ์ด Text ์ปดํฌ์ ๋ธ์ headlineLarge์์ ์ ์ธํ ๋ชจ์์ด ๋๋ค.
#2-3 Typography ํ์ฉ ์ 2
Text(
text = "Sample Top Bar Text",
fontSize = 20.sp,
style = MaterialTheme.typography.headlineLarge
)
์ด๋ฐ ๊ฒฝ์ฐ์๋ 1์ฐจ์ ์ผ๋ก headlineLarge์์ ์ ์ธํ ๋ชจ์์ ์ ์ฉํ ํ, 2์ฐจ์ ์ผ๋ก fontSize๋ฅผ ์ ์ฉํ๋ค. ์ฆ, fontSize ์์ฑ์ด ์ฐ์ ํ๋ค. ์ ์ญ์ ์ธ ์ค์ ๊ณผ ์ง์ญ์ ์ธ ์ค์ ์ด ์ถฉ๋ํ์ ๋๋ ์ด์ ๊ฐ์ด ์ง์ญ์ ์ธ ์ค์ ์ ์ฐ์ ํ๋ ๊ฒ ๋น์ฐํ๊ฒ ์ง๋ง ๋ง์ด๋ค.
#2-4 ui.theme.Typography.kt
// package com.example.nutri_capture_new.ui.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
Jetpack Compose ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ฉด ๊ธฐ๋ณธ์ผ๋ก ๋ค์ด์๋ ์ฝ๋๋ค. ์์น๋ ui.theme ํจํค์ง์ Type.kt ํ์ผ์ด๋ค. Typography ํด๋์ค๋ bodyLarge, titleLarge, labelSmall, headlineMedium, displaySmall ๋ฑ๋ฑ์ ์ ๋ง์ ๋จธํฐ๋ฆฌ์ผ ๋์์ธ ๊ธ๊ผด์ ์์ฑ์๋ก์ ๋ฐ๋๋ค. ์์ฑ์๋ฅผ ๋ฃ์ง ์์ผ๋ฉด ๊ฐ ๊ธ๊ผด์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ ์ฉ๋๋ค. ์ฆ, ๋จธํฐ๋ฆฌ์ผ ๋์์ธ ๊ธ๊ผด์ ๊ทธ๋๋ก ์ฌ์ฉํ๋ ๋ด๊ฐ ์ํ๋ ๊ฒฝ์ฐ ํจ์๋ฅผ ์ค๋ฒ๋ผ์ด๋ํ๋ฏ ์ปค์คํ ํ ์ ์๋ค๋ ์๊ธฐ๋ค.
๋ด ํ๋ก์ ํธ์ ๊ฒฝ์ฐ ์์ง ๊ธ๊ผด์ ๋ค๋ฌ๋ ๋จ๊ณ๊ฐ ์๋๊ธฐ์, ์ฐ์ ์ Typography์ ๊ธฐ๋ณธ๊ฐ์ ๊ทธ๋๋ก ์ฌ์ฉํ๊ฒ ๋ค. ๋ ๊ธฐ๋ณธ๊ฐ์ ์ฌ์ฉํ๋ ๊ฒ ๋์ ๊ฒ๋ ์๋๋ค. ๋จธํฐ๋ฆฌ์ผ ๋์์ธ ๊ถ์ฅ ์ฌํญ์ ๊ทธ๋๋ก ๋ฐ๋ฅด๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ด๋ค.
#2-5 ์ฐธ๊ณ : Typography ํด๋์ค
@Immutable
class Typography(
val displayLarge: TextStyle = TypographyTokens.DisplayLarge,
val displayMedium: TextStyle = TypographyTokens.DisplayMedium,
val displaySmall: TextStyle = TypographyTokens.DisplaySmall,
val headlineLarge: TextStyle = TypographyTokens.HeadlineLarge,
val headlineMedium: TextStyle = TypographyTokens.HeadlineMedium,
val headlineSmall: TextStyle = TypographyTokens.HeadlineSmall,
val titleLarge: TextStyle = TypographyTokens.TitleLarge,
val titleMedium: TextStyle = TypographyTokens.TitleMedium,
val titleSmall: TextStyle = TypographyTokens.TitleSmall,
val bodyLarge: TextStyle = TypographyTokens.BodyLarge,
val bodyMedium: TextStyle = TypographyTokens.BodyMedium,
val bodySmall: TextStyle = TypographyTokens.BodySmall,
val labelLarge: TextStyle = TypographyTokens.LabelLarge,
val labelMedium: TextStyle = TypographyTokens.LabelMedium,
val labelSmall: TextStyle = TypographyTokens.LabelSmall,
) {
...
}
#3 ์ฝ๋
#2-2์ ์ฝ๋๋๋ก ๊ธฐ์กด ํ๋ก์ ํธ๋ฅผ ์์ ํ๋ค.
#3-1 MainActivity.kt
...
import androidx.compose.material3.MaterialTheme
...
class MainActivity : ComponentActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
...
setContent {
NutricapturenewTheme {
...
Scaffold(
...
topBar = {
TopAppBar(
title = {
Text(
text = "Sample Top Bar Text",
style = MaterialTheme.typography.headlineLarge
)
}
)
},
bottomBar = {
...
},
snackbarHost = {
SnackbarHost(
...
snackbar = { ...
Snackbar(
...
) {
Text(
text = snackbarData.visuals.message,
style = MaterialTheme.typography.bodyLarge,
)
}
}
)
}
) { ...
...
}
}
}
}
...
}
...
@Composable
fun SampleContent(
...
) {
Box(
...
) {
Button(
...
) {
Text(
text = text,
style = MaterialTheme.typography.headlineMedium
)
}
}
}
#3-2 NutrientScreen.kt
...
import androidx.compose.material3.MaterialTheme
...
@Composable
fun NutrientScreen(
...
) {
...
LazyColumn(
...
) {
item {
FilledTonalButton(
...
) {
Text(
text = "+",
style = MaterialTheme.typography.headlineMedium
)
}
}
...
items(...) { ...
...
Card(
...
) {
Box(
...
) {
Column(
...
) {
Text(
text = DateFormatter.formatDateForNutrientScreen(dayMeal.date) + " " + dayMeal.time,
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.End,
style = MaterialTheme.typography.labelLarge
)
Text(
text = "mealId: ${dayMeal.mealId}",
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.headlineMedium
)
}
...
}
}
}
}
}
#4 ์์ฑ๋ ์ฑ
#4-1 ์คํฌ๋ฆฐ์ท

๊ฒ๋ชจ์ต์ ๋ค๋ฅผ ๊ฒ ๊ฑฐ์ ์๋ค. ํ์ง๋ง, ๋ด๋ถ ์ฝ๋๋ ๋ ๊น๋ํด์ก๋ค. ์ด ์์ ์ดํ๋ก ๊ธ์จ ํฌ๊ธฐ๋ฅผ ์ง์ญ์ ์ผ๋ก ํ ๋นํ๋ ์ผ์ด ์๋๋ก ํด์ผ๊ฒ ๋ค.
#4-2 ์ด ๊ฒ์๊ธ ์์ ์ Commit
GitHub - Kanmanemone/nutri-capture-new
Contribute to Kanmanemone/nutri-capture-new development by creating an account on GitHub.
github.com
#4-3 ๋ณธ ํ๋ก์ ํธ์ ๊ฐ์ฅ ์ต์ Commit
GitHub - Kanmanemone/nutri-capture-new
Contribute to Kanmanemone/nutri-capture-new development by creating an account on GitHub.
github.com
'๊ฐ๋ฐ ์ผ์ง ๐ป > Nutri Capture' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Nutri Capture ๋ฐฉํฅ์ฑ - ๊ฐ๋ฐ ์ผ์ ํ (1์ฐจ) (0) | 2024.12.31 |
---|---|
Nutri Capture ํ๋ก ํธ์๋ - Dimens์ ํจ๊ป ChatBar ๋ง๋ค๊ธฐ (0) | 2024.12.31 |
Nutri Capture ํ๋ก ํธ์๋ - bottomBar ๋์ ๋ณ๊ฒฝ (1) | 2024.12.18 |
Nutri Capture ๋ฐฑ์๋ - ์ด์ง ํ์ ์ ์ฉ (1) | 2024.12.17 |
Nutri Capture ํ๋ก ํธ์๋ - item ์ถ๊ฐใ์ ๊ฑฐ ์ ๋๋ฉ์ด์ (0) | 2024.12.15 |