Class Columns
列
Columns
widget 在卡片或对话框中最多可显示 2 列。您可以向每个 Column
添加微件;微件会按照指定的顺序显示。如需查看 Google Chat 应用中的示例,请参阅列。
每列的高度由较高列决定。例如,如果第一列比第二列高,则这两列的高度都与第一列相同。由于每列可以包含不同数量的 widget,因此您无法定义行或在列之间对齐 widget。
列会并排显示。您可以使用 HorizontalSizeStyle
字段自定义各列的宽度。如果用户的屏幕宽度过窄,第二列会换行显示在第一列下方:
- 在网站上,如果屏幕宽度小于或等于 480 像素,则第二列会换行。
- 在 iOS 设备上,如果屏幕宽度小于或等于 300 pt,则第二列会换行。
- 在 Android 设备上,如果屏幕宽度小于或等于 320 dp,则第二列会换行。
适用于 Google Chat 应用和 Google Workspace 插件。支持列的插件界面包括:
- 当用户从电子邮件草稿打开插件时显示的对话框。
- 当用户从 Google 日历活动中的添加附件菜单打开插件时,系统会显示的对话框。
// Build a column that is aligned in the center and fills the space:
const column =
CardService.newColumn()
.setHorizontalSizeStyle(
CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)
.setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)
.setVerticalAlignment(CardService.VerticalAlignment.CENTER);
const columns = CardService.newColumns().addColumn(column).setWrapStyle(
CardService.WrapStyle.WRAP);
详细文档
addColumn(column)
向“Columns”微件添加了 Column
。列会按添加的顺序显示。您最多可以添加两列。
const columns = CardService.newColumns().addColumn(CardService.newColumn());
参数
名称 | 类型 | 说明 |
column | Column | 要添加到 Columns 微件的子列。 |
返回
Columns
- 此对象,用于链式调用。
setWrapStyle(wrapStyle)
设置列的换行样式,控制列如何根据屏幕宽度调整大小。
const columns = CardService.newColumns()
.addColumn(CardService.newColumn())
.setWrapStyle(CardService.WrapStyle.WRAP);
参数
返回
Columns
- 此对象,用于链式调用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-30。
[null,null,["最后更新时间 (UTC):2025-01-30。"],[[["The Columns widget allows displaying up to two columns within cards or dialogs, with widgets arranged vertically within each column."],["Column height is determined by the taller column, and widgets cannot be aligned across columns or organized into rows."],["Columns are displayed side-by-side and wrap to a vertical layout on smaller screens based on specified screen width thresholds."],["Customization options include adjusting column width and controlling wrapping behavior with `HorizontalSizeStyle` and `WrapStyle` respectively."],["This widget is available for Google Chat apps and specific Google Workspace Add-ons, like dialogs in email drafts or Calendar event attachments."]]],["The Columns widget displays up to two columns in a card or dialog, with widgets added to each column in a specified order. Column height is determined by the taller column, and widths can be customized. If the screen is too narrow, the second column wraps below the first, with specific pixel/point/dp thresholds for web, iOS, and Android devices. Key actions include adding columns using `addColumn()` and controlling resizing with `setWrapStyle()`. These features are available for Google Chat and Workspace add-ons.\n"]]