Class Columns
欄
Columns
小工具最多可在資訊卡或對話方塊中顯示 2 欄。您可以為每個 Column
新增小工具,小工具會依指定的順序顯示。如需 Google Chat 應用程式的範例,請參閱「欄」。
每個資料欄的高度會由較高的資料欄決定。舉例來說,如果第一欄比第二欄高,兩個欄的高度都會是第一欄的高度。由於每個資料欄可包含不同數量的小工具,因此您無法定義列或在資料欄之間對齊小工具。
資料欄會並排顯示。您可以使用 HorizontalSizeStyle
欄位自訂每個欄的寬度。如果使用者的螢幕寬度太窄,第二欄會在第一欄下方折行:
- 在網頁上,如果螢幕寬度小於或等於 480 像素,第二欄就會換行。
- 在 iOS 裝置上,如果螢幕寬度小於或等於 300 pt,第二欄就會換行。
- 在 Android 裝置上,如果螢幕寬度小於或等於 320 dp,第二欄就會換行。
適用於 Google Chat 應用程式和 Google Workspace 外掛程式。支援資料欄的外掛程式 UI 包括:
- 使用者從電子郵件草稿開啟外掛程式時顯示的對話方塊。
- 使用者在 Google 日曆活動中透過「Add attachment」選單開啟外掛程式時,會顯示的對話方塊。
// 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)
將 Column
新增至「資料欄」小工具。系統會按照新增的順序顯示資料欄。最多可新增兩個資料欄。
const columns = CardService.newColumns().addColumn(CardService.newColumn());
參數
名稱 | 類型 | 說明 |
column | Column | 要新增至「欄」小工具的子欄。 |
回攻員
Columns
:這個物件用於鏈結。
setWrapStyle(wrapStyle)
設定欄的包覆樣式,控制欄的大小如何根據螢幕寬度調整。
const columns = CardService.newColumns()
.addColumn(CardService.newColumn())
.setWrapStyle(CardService.WrapStyle.WRAP);
參數
回攻員
Columns
:這個物件用於鏈結。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-01-30 (世界標準時間)。
[null,null,["上次更新時間: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"]]