Class CollapseControl
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.
Thu gọnChế độ điều khiển
Một chế độ điều khiển thu gọn và mở rộng có thể tuỳ chỉnh.
Có sẵn cho các ứng dụng Google Chat. Trong bản dùng thử dành cho nhà phát triển cho tiện ích bổ sung của Google Workspace.
const collapseButton =
CardService.newTextButton()
.setTextButtonStyle(CardService.TextButtonStyle.BORDERLESS)
.setText('Collapse');
const expandButton =
CardService.newImageButton()
.setImageButtonStyle(CardService.ImageButtonStyle.FILLED);
const collapseControl =
CardService.newCollapseControl()
.setHorizontalAlign(CardService.HorizontalAlignment.END)
.setExpandButton(expandButton)
.setCollapseButton(collapseButton);
Tài liệu chi tiết
setHorizontalAlign(horizontalAlignment)
Đặt HorizontalAlignment
của CollapseControl
. Không bắt buộc. *
const collapseControl = CardService.newCollapseControl().setHorizontalAlign(
CardService.HorizontalAlignment.START,
);
Thông số
Tên | Loại | Mô tả |
horizontalAlignment | HorizontalAlignment | Cách căn chỉnh theo chiều ngang của tiện ích CollapseControl. |
Cầu thủ trả bóng
CollapseControl
– Đối tượng này, để tạo chuỗi.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eCollapseControl is a customizable control that allows users to collapse and expand content within Google Chat apps and Google Workspace Add-ons (in developer preview).\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can customize the appearance and behavior of the CollapseControl using methods to set collapse and expand buttons, as well as horizontal alignment.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003esetCollapseButton\u003c/code\u003e and \u003ccode\u003esetExpandButton\u003c/code\u003e methods allow for assigning custom buttons to control the expansion and collapse actions.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003esetHorizontalAlign\u003c/code\u003e method enables developers to control the horizontal positioning of the CollapseControl within its container.\u003c/p\u003e\n"]]],[],null,["# Class CollapseControl\n\nCollapseControl\n\nA customizable collapse and expand control.\n\nAvailable for Google Chat apps. In developer preview for Google Workspace add-ons.\n\n\n| **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features.\n\n\u003cbr /\u003e\n\n```javascript\nconst collapseButton =\n CardService.newTextButton()\n .setTextButtonStyle(CardService.TextButtonStyle.BORDERLESS)\n .setText('Collapse');\n\nconst expandButton =\n CardService.newImageButton()\n .setImageButtonStyle(CardService.ImageButtonStyle.FILLED);\n\nconst collapseControl =\n CardService.newCollapseControl()\n .setHorizontalAlign(CardService.HorizontalAlignment.END)\n .setExpandButton(expandButton)\n .setCollapseButton(collapseButton);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------|\n| [setCollapseButton(button)](#setCollapseButton(Button)) | [CollapseControl](#) | Sets the [Button](/apps-script/reference/card-service/button) that is displayed for \"show less\" button. |\n| [setExpandButton(button)](#setExpandButton(Button)) | [CollapseControl](#) | Sets the [Button](/apps-script/reference/card-service/button) that is displayed for \"show more\" button. |\n| [setHorizontalAlign(horizontalAlignment)](#setHorizontalAlign(HorizontalAlignment)) | [CollapseControl](#) | Sets the [HorizontalAlignment](/apps-script/reference/card-service/horizontal-alignment) of the [CollapseControl](#). |\n\nDetailed documentation\n----------------------\n\n### `set``Collapse``Button(button)`\n\nSets the [Button](/apps-script/reference/card-service/button) that is displayed for \"show less\" button. Optional. \n\nMust be set together with collapse button.\n\n```javascript\nconst collapseButton =\n CardService.newTextButton().setText('Collapse');\n\nconst collapseControl =\n CardService.newCollapseControl()\n .setCollapseButton(collapseButton);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|------------------------------------------------------|-----------------------------|\n| `button` | [Button](/apps-script/reference/card-service/button) | The collapse button to set. |\n\n#### Return\n\n\n[CollapseControl](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Expand``Button(button)`\n\nSets the [Button](/apps-script/reference/card-service/button) that is displayed for \"show more\" button. Optional. \n\nMust be set together with collapse button.\n\n```javascript\nconst expandButton =\n CardService.newTextButton().setText('Expand');\n\nconst collapseControl =\n CardService.newCollapseControl()\n .setExpandButton(expandButton);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|------------------------------------------------------|---------------------------|\n| `button` | [Button](/apps-script/reference/card-service/button) | The expand button to set. |\n\n#### Return\n\n\n[CollapseControl](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Horizontal``Align(horizontalAlignment)`\n\nSets the [HorizontalAlignment](/apps-script/reference/card-service/horizontal-alignment) of the [CollapseControl](#). Optional. \\*\n\n```javascript\nconst collapseControl = CardService.newCollapseControl().setHorizontalAlign(\n CardService.HorizontalAlignment.START,\n);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-------------------------|---------------------------------------------------------------------------------|---------------------------------------------------------|\n| `horizontal``Alignment` | [HorizontalAlignment](/apps-script/reference/card-service/horizontal-alignment) | The horizontal alignment of the CollapseControl widget. |\n\n#### Return\n\n\n[CollapseControl](#) --- This object, for chaining."]]