Class CollapseControl

  • CollapseControl is a customizable control that allows users to collapse and expand content within Google Chat apps and Google Workspace Add-ons (in developer preview).

  • Developers can customize the appearance and behavior of the CollapseControl using methods to set collapse and expand buttons, as well as horizontal alignment.

  • setCollapseButton and setExpandButton methods allow for assigning custom buttons to control the expansion and collapse actions.

  • setHorizontalAlign method enables developers to control the horizontal positioning of the CollapseControl within its container.

CollapseControl

A customizable collapse and expand control.

Available for Google Chat apps. In developer preview for Google Workspace add-ons.

constcollapseButton=
CardService.newTextButton()
.setTextButtonStyle(CardService.TextButtonStyle.BORDERLESS)
.setText('Collapse');
constexpandButton=
CardService.newImageButton()
.setImageButtonStyle(CardService.ImageButtonStyle.FILLED);
constcollapseControl=
CardService.newCollapseControl()
.setHorizontalAlign(CardService.HorizontalAlignment.END)
.setExpandButton(expandButton)
.setCollapseButton(collapseButton);

Methods

MethodReturn typeBrief description
setCollapseButton(button) CollapseControl Sets the Button that is displayed for "show less" button.
setExpandButton(button) CollapseControl Sets the Button that is displayed for "show more" button.
setHorizontalAlign(horizontalAlignment) CollapseControl Sets the HorizontalAlignment of the CollapseControl .

Detailed documentation

setCollapseButton(button)

Sets the Button that is displayed for "show less" button. Optional.
Must be set together with collapse button.

constcollapseButton=
CardService.newTextButton().setText('Collapse');
constcollapseControl=
CardService.newCollapseControl()
.setCollapseButton(collapseButton);

Parameters

NameTypeDescription
buttonButton The collapse button to set.

Return

CollapseControl — This object, for chaining.


setExpandButton(button)

Sets the Button that is displayed for "show more" button. Optional.
Must be set together with collapse button.

constexpandButton=
CardService.newTextButton().setText('Expand');
constcollapseControl=
CardService.newCollapseControl()
.setExpandButton(expandButton);

Parameters

NameTypeDescription
buttonButton The expand button to set.

Return

CollapseControl — This object, for chaining.


setHorizontalAlign(horizontalAlignment)

Sets the HorizontalAlignment of the CollapseControl . Optional. *

constcollapseControl=CardService.newCollapseControl().setHorizontalAlign(
CardService.HorizontalAlignment.START,
);

Parameters

NameTypeDescription
horizontalAlignmentHorizontalAlignment The horizontal alignment of the CollapseControl widget.

Return

CollapseControl — This object, for chaining.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年01月30日 UTC.