KDY

Android Compose Text λ³Έλ¬Έ

Android

Android Compose Text

daeyeong 2025. 5. 23. 22:35
Jetpack Compose Text κΈ°λ³Έ μ‚¬μš©λ²•

πŸ“ Jetpack Compose Text κΈ°λ³Έ μ‚¬μš©λ²•

이번 ν¬μŠ€νŒ…μ—μ„œλŠ” Text 컴포저블을 μ‚¬μš©ν•˜μ—¬ ν…μŠ€νŠΈ μŠ€νƒ€μΌμ„ μ„€μ •ν•˜λŠ” 방법을 λ‹¨κ³„λ³„λ‘œ μ†Œκ°œν•΄λ“œλ¦΄κ²Œμš” 😊

1. 색상 μ§€μ •ν•˜κΈ°

color μ†μ„±μœΌλ‘œ ν…μŠ€νŠΈμ˜ 색상을 μ§€μ •ν•  수 μžˆμ–΄μš”.

Text(color = Color.Red, text = "Hello")

μœ„ μ½”λ“œλŠ” ν…μŠ€νŠΈ 색상을 λΉ¨κ°„μƒ‰μœΌλ‘œ μ§€μ •ν•œ μ˜ˆμž…λ‹ˆλ‹€.

2. ν•΄μ‹œκ°’μœΌλ‘œ 색상 μ§€μ •

ARGB ν˜•μ‹μ˜ 16μ§„μˆ˜ ν•΄μ‹œκ°’μœΌλ‘œ 색상을 직접 μž…λ ₯ν•  μˆ˜λ„ μžˆμ–΄μš”.

Text(color = Color(0xfff999bb), text = "Hello")
  • ff: μ•ŒνŒŒ(투λͺ…도)
  • f999bb: RGB κ°’

3. κΈ€μž 크기 μ‘°μ •

fontSize μ†μ„±μœΌλ‘œ ν…μŠ€νŠΈ 크기λ₯Ό μ„€μ •ν•΄μš”.

Text(text = "Hello", fontSize = 30.sp)

4. ν…μŠ€νŠΈ λ‘κ»˜

fontWeight둜 κΈ€μžμ˜ κ΅΅κΈ°λ₯Ό μ‘°μ •ν•  수 μžˆμ–΄μš”.

Text(text = "Hello", fontWeight = FontWeight.Bold)

5. 폰트 λ³€κ²½

fontFamily μ†μ„±μœΌλ‘œ λ‹€μ–‘ν•œ 폰트λ₯Ό μ μš©ν•΄λ³΄μ„Έμš”.

Text(text = "Hello", fontFamily = FontFamily.Cursive)

↔ 6. 문자 간격

letterSpacing은 κΈ€μž μ‚¬μ΄μ˜ 간격을 μ‘°μ •ν•©λ‹ˆλ‹€.

Text(text = "Hello", letterSpacing = 2.sp)

7. μ΅œλŒ€ 쀄 수 μ œν•œ

maxLinesλ₯Ό μ΄μš©ν•΄ ν…μŠ€νŠΈκ°€ λͺ‡ μ€„κΉŒμ§€ ν‘œμ‹œλ μ§€ μ œν•œν•  수 μžˆμ–΄μš”.

Text(text = "Hello\nHello\nHello", maxLines = 2)

8. ν…μŠ€νŠΈ μž₯식

밑쀄

Text(text = "Hello", textDecoration = TextDecoration.Underline)

μ·¨μ†Œμ„ 

Text(text = "Hello", textDecoration = TextDecoration.LineThrough)

밑쀄 + μ·¨μ†Œμ„ 

Text(
  text = "Hello",
  textDecoration = TextDecoration.combine(
    listOf(TextDecoration.Underline, TextDecoration.LineThrough)
  )
)

μž₯식 μ—†μŒ

Text(text = "Hello", textDecoration = TextDecoration.None)

9. ν…μŠ€νŠΈ μ •λ ¬

textAlign μ†μ„±μœΌλ‘œ ν…μŠ€νŠΈμ˜ μ •λ ¬ 방식을 μ„€μ •ν•  수 μžˆμ–΄μš”.

Text(modifier = Modifier.size(300.dp), text = "Hello", textAlign = TextAlign.Center)
  • width: κ°€λ‘œ 크기
  • height: μ„Έλ‘œ 크기

✨ μΆ”κ°€ 팁

  • fontFamilyλ₯Ό μ»€μŠ€ν„°λ§ˆμ΄μ§•ν•˜λ©΄ κ°œμ„± μžˆλŠ” μŠ€νƒ€μΌλ„ κ°€λŠ₯ν•΄μš”!
  • μ™ΈλΆ€ 라이브러리λ₯Ό 톡해 λ‹€μ–‘ν•œ 글꼴을 μΆ”κ°€ν•΄λ³΄μ„Έμš”.

'Android' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

κ΅°λŒ€μ—μ„œ μ•ˆλ“œλ‘œμ΄λ“œ κ°œλ°œν•˜κΈ°  (0) 2025.05.21
Android Okhttp Logging Multipart λ¬΄μ‹œν•˜κΈ°  (0) 2022.09.30
Android BindingAdapter  (0) 2022.05.10
Android DataBinding  (0) 2022.05.02
Android dp와sp의 차이  (0) 2022.04.29