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

Row: วางสิ่งต่าง ๆ เคียงข้างกัน

จัดวางองค์ประกอบลูกจากซ้ายไปขวา

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

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

Side by Side

When you want children in a horizontal line, you use a Row. It is the sideways sibling of Column. ➡️

Your First Row

A Row takes a trailing lambda just like Column. Each child you call inside lands next to the previous one, left to right.

Row {
    Text("Left")
    Text("Right")
}

Order Is Left to Right

Children flow in source order across the screen. The first Composable sits at the start, the next beside it, and so on.

A Classic Icon Plus Label

Rows shine for small pairs, like an Icon next to a Text label. That side-by-side combo is everywhere in real apps.

Row {
    Icon(Icons.Default.Star, null)
    Text("Favorite")
}

Spacing Between Children

Use horizontalArrangement with spacedBy to drop an even gap between each child instead of padding them one by one.

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
    Text("A")
    Text("B")
}

Aligning Children Vertically

Set verticalAlignment to line children up across the row's height. CenterVertically keeps an icon and tall text neatly centered.

Row(verticalAlignment = Alignment.CenterVertically) {
    Icon(Icons.Default.Star, null)
    Text("Centered")
}

Pushing Items Apart

Arrangement.SpaceBetween pins the first child to the start and the last to the end, spreading any extra space between them.

Row(horizontalArrangement = Arrangement.SpaceBetween) {
    Text("Start")
    Text("End")
}

Sharing Space with Weight

Give a child weight in its modifier to make it claim the leftover width. Two equal weights split the row evenly.

Row {
    Text("Half", Modifier.weight(1f))
    Text("Half", Modifier.weight(1f))
}

Rows Don't Scroll Yet

A plain Row does not scroll. Children that overflow the width get clipped, so keep a basic Row to content that fits.

Adding Horizontal Scroll

For wide content, attach horizontalScroll to the Row's modifier and the whole strip becomes swipeable sideways.

Row(modifier = Modifier.horizontalScroll(rememberScrollState())) {
    Text("Wide content")
}

Rows Inside Columns

Most screens combine both. A Column stacks sections vertically while each section uses a Row to lay its pieces side by side.

Quick Check

Let's confirm how a Row lays out its children.

Recap: Row

You learned Row: it places children left to right, uses arrangement and alignment to position them, and shares width with weight for flexible layouts.

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

บทเรียน “Row: วางสิ่งต่าง ๆ เคียงข้างกัน” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “Row: วางสิ่งต่าง ๆ เคียงข้างกัน”

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

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

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

บทเรียน “Row: วางสิ่งต่าง ๆ เคียงข้างกัน” ใช้เวลานานแค่ไหน

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

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

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

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

  1. Column: เรียงสิ่งต่าง ๆ ในแนวตั้ง
  2. Row: วางสิ่งต่าง ๆ เคียงข้างกัน
  3. Box: ซ้อนและทับซ้อน
  4. การจัดเรียงและการจัดแนว
← กลับไปที่ Jetpack Compose Academy