Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
เริ่มใช้งาน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
This page describes how to implement basic Grid layouts.
Set up project
Add the androidx.compose.foundation.layout library to your project's
lib.versions.toml.
[versions]
compose = "1.12.0-alpha02"
[libraries]
androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout", version.ref = "compose" }
Add the library dependency to your app's build.gradle.kts.
dependencies {
implementation(libs.androidx.compose.foundation.layout)
}
Create a basic grid
The following example creates a basic 2x3 grid,
with the columns and rows having a fixed size of 100.dp.
Grid(
config = {
repeat(2) {
column(100.dp)
}
repeat(3) {
row(100.dp)
}
}
) {
Card1(containerColor = PastelRed)
Card2(containerColor = PastelGreen)
Card3(containerColor = PastelBlue)
Card4(containerColor = PastelPink)
Card5(containerColor = PastelOrange)
Card6(containerColor = PastelYellow)
}
Figure 1.
A basic grid consists of rows and columns with fixed size.
To learn how to implement more advanced grids,
see Set container properties and Set item properties.
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2026-05-06 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2026-05-06 UTC"],[],[]]