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.
Bản xem trước của Compose là một công cụ mạnh mẽ để trực quan hoá các thành phần kết hợp tại thời điểm thiết kế trong Android Studio, nhưng việc thiết lập dữ liệu mô phỏng theo cách thủ công cho các tham số xem trước có thể tốn thời gian. Gemini trong Android Studio có một tính năng giúp giải quyết vấn đề này: tự động tạo bản xem trước Compose.
Bạn có thể truy cập vào công cụ này theo 2 cách:
Trong bất kỳ thành phần kết hợp nào, hãy nhấp chuột phải rồi chuyển đến Gemini > Generate "<composable>" Preview (Tạo bản xem trước "<thành phần kết hợp>") hoặc Generate Compose Previews for this file (Tạo bản xem trước Compose cho tệp này).
Nếu bạn chưa thiết lập bản xem trước nào, hãy nhấp vào Tự động tạo bản xem trước Compose cho tệp này trong bảng xem trước trống.
Khi yêu cầu Gemini tạo bản xem trước Compose, bạn sẽ nhận được một chế độ xem chênh lệch với mã xem trước Compose mà Gemini đề xuất. Tại đây, bạn có thể chấp nhận hoặc từ chối các thay đổi được đề xuất. Mã của Gemini sẽ là điểm khởi đầu hữu ích để đẩy nhanh quy trình phát triển của bạn.
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-07-31 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-07-31 UTC."],[],[],null,["# Generate Compose previews\n\n| **Preview:** Enable Compose preview generation through [Studio Labs](/studio/gemini/labs).\n\n[Compose previews](/develop/ui/compose/tooling/previews) are a powerful tool for\nvisualizing composables at design time in Android Studio, but manually setting\nup mock data for the preview parameters can be time-consuming. Gemini in Android\nStudio includes a feature that solves this problem: automated Compose preview\ngeneration.\n\nYou can access this tool in two ways:\n\n- Within any composable, right-click and navigate to **Gemini \\\u003e Generate\n \"\\\u003ccomposable\\\u003e\" Preview** or **Generate Compose Previews for this file**.\n\n | **Note:** You only see the option to generate Compose previews for the whole file if there are multiple composables in the file that don't have associated previews.\n\n- If you don't have any previews set up yet, in the empty preview panel click\n **Auto-generate Compose Previews for this file**.\n\nWhen you ask Gemini to generate Compose previews, you get a diff view with\nGemini's suggested Compose preview code where you can accept or reject the\nproposed changes. Gemini's code should provide a valuable starting point to\naccelerate your development workflow."]]