การตั้งค่าข้อมูลโดยย่อ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หน้านี้จะอธิบายวิธีตั้งค่าสภาพแวดล้อมในการพัฒนาเพื่อใช้ Glance
คุณดาวน์โหลดเวอร์ชันล่าสุดที่มีได้จากหน้าการเผยแพร่
เพิ่มการอ้างอิง Glance ที่เฉพาะเจาะจงในโมดูลของแอปตามประเภทของ
"Glanceable" ที่คุณต้องการสร้าง
dependencies {
// For AppWidgets support
implementation "androidx.glance:glance-appwidget:1.1.1"
// For interop APIs with Material 3
implementation "androidx.glance:glance-material3:1.1.1"
// For interop APIs with Material 2
implementation "androidx.glance:glance-material:1.1.1"
}
เปิดใช้งานคอมไพเลอร์ Compose
ตั้งค่าตัวเลือกต่อไปนี้เพื่อให้มั่นใจว่าคอมไพเลอร์ Compose พร้อมใช้งานสำหรับ
Glance
android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
kotlinOptions {
jvmTarget = "1.8"
}
}
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 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"]],["อัปเดตล่าสุด 2025-08-27 UTC"],[],[],null,["This page describes how to set up your development environment to use Glance.\nYou can get the latest available version from\n[the release page](/jetpack/androidx/releases/glance).\n\nAdd the specific Glance dependency in your app's module based on the type of\n\"glanceable\" you want to build. \n\n dependencies {\n // For AppWidgets support\n implementation \"androidx.glance:glance-appwidget:1.1.1\"\n\n // For interop APIs with Material 3\n implementation \"androidx.glance:glance-material3:1.1.1\"\n\n // For interop APIs with Material 2\n implementation \"androidx.glance:glance-material:1.1.1\"\n }\n\nActivate Compose compiler\n\nSet the following options to ensure that the Compose compiler is available for\nGlance: \n\n\n android {\n buildFeatures {\n compose true\n }\n\n composeOptions {\n kotlinCompilerExtensionVersion = \"1.5.15\"\n }\n\n kotlinOptions {\n jvmTarget = \"1.8\"\n }\n }"]]