Class CollapseControl
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การควบคุมการยุบ
การควบคุมแบบยุบและขยายที่กำหนดเองได้
พร้อมใช้งานสำหรับแอป Google Chat อยู่ในเวอร์ชันตัวอย่างสำหรับนักพัฒนาซอฟต์แวร์สำหรับส่วนเสริมของ 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);
เอกสารประกอบโดยละเอียด
setHorizontalAlign(horizontalAlignment)
ตั้งค่า HorizontalAlignment
ของ CollapseControl
ไม่บังคับ *
const collapseControl = CardService.newCollapseControl().setHorizontalAlign(
CardService.HorizontalAlignment.START,
);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
horizontalAlignment | HorizontalAlignment | การจัดแนวแนวนอนของวิดเจ็ต CollapseControl |
รีเทิร์น
CollapseControl
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 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."]]