Thiết lập nhanh
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này mô tả cách thiết lập môi trường phát triển để sử dụng Glance.
Bạn có thể tải phiên bản mới nhất hiện có trên trang phát hành.
Thêm phần phụ thuộc Glance cụ thể vào mô-đun của ứng dụng dựa trên loại "thông tin có thể xem nhanh" mà bạn muốn tạo.
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"
}
Kích hoạt trình biên dịch Compose
Đặt các lựa chọn sau để đảm bảo rằng trình biên dịch Compose có sẵn cho Glance:
android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
kotlinOptions {
jvmTarget = "1.8"
}
}
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-21 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-21 UTC."],[],[],null,["# Glance setup\n\nThis 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-------------------------\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 }"]]