0Pricing
Jetpack Compose Academy · บทเรียน

Scaffold: โครงร่างหน้าจอ

เชื่อมช่องของเลย์เอาต์แอปมาตรฐานเข้าด้วยกัน

Scaffold: โครงร่างหน้าจอ เป็นบทเรียน Jetpack Compose Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Jetpack Compose Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Meet Scaffold

Most app screens share the same skeleton: a bar on top, content in the middle, maybe a button floating below. Scaffold gives you all of that in one Composable. 🏗️

Why Not Just a Column?

You could hand-build bars with a Column, but you would re-solve insets, spacing, and overlaps every time. Scaffold wires those standard pieces together for you.

The Slot Idea

Scaffold works with slots: named spots where you drop a Composable. You fill the slots you want and leave the rest empty.

The content Slot

The one slot you almost always use is content. It is the main body of your screen, and Scaffold hands it the right padding to use.

Scaffold { innerPadding ->
    Text("Hello", Modifier.padding(innerPadding))
}

Honor innerPadding

That innerPadding keeps your content from hiding under bars. Always apply it to your top-level content, or text can slip beneath the app bar.

The topBar Slot

Drop a bar into the topBar slot and Scaffold pins it to the top, then shrinks the content area so nothing overlaps.

Scaffold(
    topBar = { TopAppBar(title = { Text("Home") }) }
) { padding -> }

More Slots Available

Scaffold also offers bottomBar, floatingActionButton, and snackbarHost slots. You will meet each one in this course.

Leave Slots Empty

Every slot is optional. A Scaffold with only content is perfectly valid, so you add bars only when a screen actually needs them.

One Scaffold Per Screen

The usual rule is one Scaffold per screen. It frames that whole screen, while smaller Composables fill its content slot.

Scaffold Is Material 3

Import Scaffold from androidx.compose.material3 so its colors and spacing match the rest of your Material You theme.

import androidx.compose.material3.Scaffold

containerColor

Set containerColor to paint the screen background behind every slot. Skip it and Scaffold uses your theme's surface color by default.

Quick Check

What is the safest thing to do with the value Scaffold passes to its content lambda?

Recap

Scaffold is your screen skeleton: fill named slots like content and topBar, honor innerPadding, and use one per screen. Next you will style the top bar. 👍

คำถามที่พบบ่อย

บทเรียน “Scaffold: โครงร่างหน้าจอ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “Scaffold: โครงร่างหน้าจอ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Jetpack Compose Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “Scaffold: โครงร่างหน้าจอ”

เชื่อมช่องของเลย์เอาต์แอปมาตรฐานเข้าด้วยกัน คุณปฏิบัติ Jetpack Compose Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Jetpack Compose Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Jetpack Compose Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “Scaffold: โครงร่างหน้าจอ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Jetpack Compose Academy นี้ได้ไหม

ได้ บทเรียน Jetpack Compose Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. Scaffold: โครงร่างหน้าจอ
  2. TopAppBar และไอคอนการดำเนินการ
  3. แถบด้านล่างและปุ่มการดำเนินการลอย
  4. Snackbar และ SnackbarHostState
← กลับไปที่ Jetpack Compose Academy