ขนาด น้ำหนัก และรูปแบบตัวอักษร
ทำให้ข้อความเป็นตัวหนา ตัวเอียง และมีขนาดเหมาะสม
ขนาด น้ำหนัก และรูปแบบตัวอักษร เป็นบทเรียน Jetpack Compose Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Jetpack Compose Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Style Your Text
Plain words are fine, but real apps need emphasis. Text accepts simple arguments to control size, weight, and style without any XML.
Set the Size
Use fontSize to make text bigger or smaller. Sizes use the sp unit, which respects the user accessibility font settings.
Text("Big title", fontSize = 24.sp)Why sp, Not dp
Text uses sp so it scales with the system font size. Layout uses dp, but words should grow when a user prefers larger text.
Make It Bold
Reach for fontWeight when you want emphasis. FontWeight.Bold is the everyday choice for titles and important labels.
Text("Headline", fontWeight = FontWeight.Bold)Weights Are a Scale
Weight is more than bold or not. FontWeight ranges from Light to Black, so you can dial in exactly the emphasis a design asks for.
FontWeight.Light
FontWeight.Medium
FontWeight.BlackAdd Italics
Slant your text with fontStyle. FontStyle.Italic is great for quotes, captions, or a subtle hint of personality.
Text("a note", fontStyle = FontStyle.Italic)Mix Them Together
These arguments combine freely. One Text call can be large, bold, and italic at once, all in a single readable line of code. 🙂
Text("Wow", fontSize = 20.sp,
fontWeight = FontWeight.Bold)Change the Font Family
Swap the typeface with fontFamily. Built-ins like Serif and Monospace ship for free, and you can load custom fonts too.
Text("code", fontFamily = FontFamily.Monospace)Letter Spacing
For airy, polished headings, nudge letterSpacing. A little extra space between characters can make uppercase titles feel premium.
Text("MENU", letterSpacing = 2.sp)Lean on Theme Styles
Instead of setting each value, pass a ready-made style from MaterialTheme. It keeps every screen visually consistent.
Text("Title", style = MaterialTheme.typography.titleLarge)Small Touches, Big Polish
Size, weight, and style are tiny arguments, but together they turn flat text into a clear hierarchy users instantly understand.
Quick Check
Which unit should you give to fontSize, and why?
Recap
You styled text with fontSize, fontWeight, fontStyle, and family. Use sp for sizing, and prefer theme typography for a consistent look. 🎨
คำถามที่พบบ่อย
บทเรียน “ขนาด น้ำหนัก และรูปแบบตัวอักษร” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ขนาด น้ำหนัก และรูปแบบตัวอักษร” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Jetpack Compose Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ขนาด น้ำหนัก และรูปแบบตัวอักษร”
ทำให้ข้อความเป็นตัวหนา ตัวเอียง และมีขนาดเหมาะสม คุณปฏิบัติ Jetpack Compose Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Jetpack Compose Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Jetpack Compose Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ขนาด น้ำหนัก และรูปแบบตัวอักษร” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Jetpack Compose Academy นี้ได้ไหม
ได้ บทเรียน Jetpack Compose Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- Composable Text
- ขนาด น้ำหนัก และรูปแบบตัวอักษร
- สี การจัดแนว และเนื้อหาล้น
- AnnotatedString: ข้อความผสมแบบมีรูปแบบ