Class Column

  • A column is a UI element available for Google Chat apps and Google Workspace Add-ons used to arrange widgets vertically within a card.

  • Developers can add various widgets like text paragraphs, images, buttons, and input fields to a column using the addWidget() method.

  • Columns offer customization options for horizontal and vertical alignment, as well as horizontal size, through methods like setHorizontalAlignment(), setVerticalAlignment(), and setHorizontalSizeStyle().

  • Widgets within a column are displayed in the order they are added using the addWidget method, allowing for structured layout design.

  • The setHorizontalAlignment, setHorizontalSizeStyle, and setVerticalAlignment methods are optional and can be used to fine-tune the appearance and layout behavior of the column.

Column

A column.

Available for Google Chat apps and Google Workspace add-ons.

constcolumnWidget=CardService.newTextParagraph();
constcolumn=
CardService.newColumn()
.setHorizontalSizeStyle(
CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)
.setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)
.setVerticalAlignment(CardService.VerticalAlignment.CENTER)
.addWidget(columnWidget);

Detailed documentation

addWidget(widget)

Adds a widget to the column.

Widgets are displayed in the order they are added. You can add the following widgets to a column:

constcolumn=CardService.newColumn().addWidget(
CardService.newTextParagraph().setText('This is a text paragraph widget'),
);

Parameters

NameTypeDescription
widgetWidget The widget to add to the column.

Return

Column — This object, for chaining.


setHorizontalAlignment(horizontalAlignment)

Sets the HorizontalAlignment of the Column . Optional.

constcolumn=CardService.newColumn().setHorizontalAlignment(
CardService.HorizontalAlignment.CENTER,
);

Parameters

NameTypeDescription
horizontalAlignmentHorizontalAlignment The horizontal alignment of the column.

Return

Column — This object, for chaining.


setHorizontalSizeStyle(horizontalSizeStyle)

Sets the HorizontalSizeStyle of the Column. Optional.

constcolumn=CardService.newColumn().setHorizontalSizeStyle(
CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE,
);

Parameters

NameTypeDescription
horizontalSizeStyleHorizontalSizeStyle The horizontal size of the column.

Return

Column — This object, for chaining.


setVerticalAlignment(verticalAlignment)

Sets the VerticalAlignment of the Column . Optional.

constcolumn=CardService.newColumn().setVerticalAlignment(
CardService.VerticalAlignment.CENTER,
);

Parameters

NameTypeDescription
verticalAlignmentVerticalAlignment The vertical alignment of the column.

Return

Column — 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.