Class MaterialIcon
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Material 图标
支持所有 Google 字体图标的对象。
适用于 Google Workspace 插件和 Google Chat 应用。
const materialIcon = CardService.newMaterialIcon()
.setName('search')
.setFill(true)
.setWeight(400)
.setGrade(0);
详细文档
setFill(fill)
图标是否以填充状态呈现。默认值为 false
。
如需预览不同的图标设置,请前往 Google 字体图标,然后调整自定义下的设置。
const materialIcon =
CardService.newMaterialIcon().setName('search').setFill(true);
参数
名称 | 类型 | 说明 |
fill | Boolean | 图标是否已填充。 |
返回
MaterialIcon
- 此对象,用于链式调用。
setGrade(grade)
Weight 和 Grade 会影响符号的粗细。调整 Grade 比调整 Weight 更精细,对符号大小的影响较小。请从 {-25, 0, 200} 中进行选择。如果不存在,则默认值为 0。如果指定任何其他值,则使用默认值。
如需预览不同的图标设置,请前往 Google 字体图标,然后调整自定义下的设置。
const materialIcon =
CardService.newMaterialIcon().setName('search').setGrade(200);
参数
名称 | 类型 | 说明 |
grade | Integer | 图标的等级。 |
返回
MaterialIcon
- 此对象,用于链式调用。
setName(name)
设置图标的名称。必填。
Google 字体图标中定义的图标名称,例如 check_box
。
系统会舍弃所有无效名称并将其替换为空字符串,这会导致图标无法呈现。
const materialIcon = CardService.newMaterialIcon().setName('search');
参数
返回
MaterialIcon
- 此对象,用于链式调用。
setWeight(weight)
图标的描边粗细。请从 {100, 200, 300, 400, 500, 600, 700} 中进行选择。如果不存在,默认值为 400。如果指定任何其他值,则使用默认值。
如需预览不同的图标设置,请前往 Google 字体图标,然后调整自定义下的设置。
const materialIcon =
CardService.newMaterialIcon().setName('search').setWeight(700);
参数
名称 | 类型 | 说明 |
weight | Integer | 图标的描边粗细。 |
返回
MaterialIcon
- 此对象,用于链式调用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eMaterialIcon\u003c/code\u003e objects allow you to use and customize \u003ca href=\"https://fonts.google.com/icons\"\u003eGoogle Font Icons\u003c/a\u003e within Google Workspace Add-ons and Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the icon's appearance by setting its fill, grade, name, and weight using methods like \u003ccode\u003esetFill()\u003c/code\u003e, \u003ccode\u003esetGrade()\u003c/code\u003e, \u003ccode\u003esetName()\u003c/code\u003e, and \u003ccode\u003esetWeight()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the \u003ca href=\"https://fonts.google.com/icons\"\u003eGoogle Font Icons\u003c/a\u003e website to preview different icon settings and find valid icon names.\u003c/p\u003e\n"],["\u003cp\u003eWhen setting grade and weight, ensure you use the accepted values or the default values will be applied.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esetName()\u003c/code\u003e method is required and uses the icon name as defined on the Google Font Icons website; using an invalid name will result in the icon not rendering.\u003c/p\u003e\n"]]],[],null,["# Class MaterialIcon\n\nMaterialIcon\n\nAn object that supports all [Google Font Icons](https://fonts.google.com/icons).\n\nAvailable for Google Workspace add-ons and Google Chat apps.\n\n```javascript\nconst materialIcon = CardService.newMaterialIcon()\n .setName('search')\n .setFill(true)\n .setWeight(400)\n .setGrade(0);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------|-------------------|-----------------------------------------------|\n| [setFill(fill)](#setFill(Boolean)) | [MaterialIcon](#) | Whether the icon renders as filled. |\n| [setGrade(grade)](#setGrade(Integer)) | [MaterialIcon](#) | Weight and grade affect a symbol's thickness. |\n| [setName(name)](#setName(String)) | [MaterialIcon](#) | Sets the name of the icon. |\n| [setWeight(weight)](#setWeight(Integer)) | [MaterialIcon](#) | The stroke weight of the icon. |\n\nDetailed documentation\n----------------------\n\n### `set``Fill(fill)`\n\nWhether the icon renders as filled. Default value is `false`.\n\nTo preview different icon settings, go to [Google\nFont Icons](https://fonts.google.com/icons) and adjust the settings under **Customize**.\n\n```javascript\nconst materialIcon =\n CardService.newMaterialIcon().setName('search').setFill(true);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|-----------|-----------------------------|\n| `fill` | `Boolean` | Whether the icon is filled. |\n\n#### Return\n\n\n[MaterialIcon](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Grade(grade)`\n\nWeight and grade affect a symbol's thickness. Adjustments to grade are more granular than\nadjustments to weight and have a small impact on the size of the symbol. Choose from {-25, 0,\n200}. If absent, default value is 0. If any other value is specified, the default value is\nused.\n\nTo preview different icon settings, go to [Google\nFont Icons](https://fonts.google.com/icons) and adjust the settings under **Customize**.\n\n```javascript\nconst materialIcon =\n CardService.newMaterialIcon().setName('search').setGrade(200);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|-----------|-------------------|\n| `grade` | `Integer` | The icon's grade. |\n\n#### Return\n\n\n[MaterialIcon](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Name(name)`\n\nSets the name of the icon. Required.\n\nThe icon name defined in [Google Font Icon](https://fonts.google.com/icons), For\nexample, `check_box`.\n\nAny invalid names are abandoned and replaced with an empty string and results in the icon\nfailing to render.\n\n```javascript\nconst materialIcon = CardService.newMaterialIcon().setName('search');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|-----------------------|\n| `name` | `String` | The name of the icon. |\n\n#### Return\n\n\n[MaterialIcon](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Weight(weight)`\n\nThe stroke weight of the icon. Choose from {100, 200, 300, 400, 500, 600, 700}. If absent,\ndefault value is 400. If any other value is specified, the default value is used.\n\nTo preview different icon settings, go to [Google\nFont Icons](https://fonts.google.com/icons) and adjust the settings under **Customize**.\n\n```javascript\nconst materialIcon =\n CardService.newMaterialIcon().setName('search').setWeight(700);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|-----------|--------------------------------|\n| `weight` | `Integer` | The stroke weight of the icon. |\n\n#### Return\n\n\n[MaterialIcon](#) --- This object, for chaining."]]