Class IconImage
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ไอคอนรูปภาพ
ไอคอนที่กำหนดไว้ล่วงหน้า ไอคอนการออกแบบวัสดุ หรือไอคอนจาก URL ที่มีสไตล์การครอบตัดที่ปรับแต่งได้
เอกสารประกอบโดยละเอียด
setAltText(altText)
ตั้งค่าข้อความแสดงแทนของ URL ซึ่งใช้สําหรับการช่วยเหลือพิเศษ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
altText | String | ข้อความแสดงแทน |
รีเทิร์น
IconImage
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setIcon(icon)
ตั้งค่าไอคอนที่กำหนดไว้ล่วงหน้าหากไม่ได้ตั้งค่า URL ค่าเริ่มต้นคือ NONE
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
icon | Icon | ค่า Icon ที่กําหนดไว้ล่วงหน้าค่าใดค่าหนึ่ง |
รีเทิร์น
IconImage
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setIconUrl(url)
ตั้งค่า URL ของไอคอนหากไม่ได้ตั้งค่าไอคอนไว้
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
url | String | ที่อยู่ URL ของรูปภาพที่โฮสต์ไว้เพื่อใช้เป็นไอคอน |
รีเทิร์น
IconImage
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setImageCropType(imageCropType)
กำหนดรูปแบบการครอบตัดสำหรับรูปภาพ ตัวเลือกประเภทการครอบตัดที่คุณใช้กับไอคอนได้มี SQUARE
และ CIRCLE
ค่าเริ่มต้นคือ SQUARE
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
imageCropType | ImageCropType | ตัวเลือก ImageCropType ที่จะใช้ |
รีเทิร์น
IconImage
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setMaterialIcon(icon)
ตั้งค่าไอคอน Material Design
const iconImage = CardService.newIconImage().setMaterialIcon(
CardService.newMaterialIcon().setName('search'),
);
พารามิเตอร์
รีเทิร์น
IconImage
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eIconImage\u003c/code\u003e allows you to display a predefined or custom icon using a URL.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the icon's appearance with a specific crop style (SQUARE or CIRCLE).\u003c/p\u003e\n"],["\u003cp\u003eAlternative text can be set for accessibility purposes using \u003ccode\u003esetAltText()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esetIcon()\u003c/code\u003e and \u003ccode\u003esetIconUrl()\u003c/code\u003e methods allow you to specify the icon source, either a predefined icon or a URL.\u003c/p\u003e\n"],["\u003cp\u003eAll methods return the \u003ccode\u003eIconImage\u003c/code\u003e object, enabling method chaining for streamlined configuration.\u003c/p\u003e\n"]]],["The `IconImage` object allows setting an icon using predefined options, a material design icon, or a URL. Key actions include: setting alternative text for accessibility (`setAltText`), choosing a predefined icon (`setIcon`), specifying an icon URL (`setIconUrl`), defining the image crop style (`setImageCropType`), and selecting a material design icon (`setMaterialIcon`). Each method returns the `IconImage` object for chaining additional actions.\n"],null,["# Class IconImage\n\nIconImage\n\nA predefined icon, a material design icon, or an icon from a URL with a customizable crop style. \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------------------|----------------|-----------------------------------------------------------------------|\n| [setAltText(altText)](#setAltText(String)) | [IconImage](#) | Sets the alternative text of the URL which is used for accessibility. |\n| [setIcon(icon)](#setIcon(Icon)) | [IconImage](#) | Sets the predefined icon if the URL is not set. |\n| [setIconUrl(url)](#setIconUrl(String)) | [IconImage](#) | Sets the URL of the icon if the icon is not set. |\n| [setImageCropType(imageCropType)](#setImageCropType(ImageCropType)) | [IconImage](#) | Sets the crop style for the image. |\n| [setMaterialIcon(icon)](#setMaterialIcon(MaterialIcon)) | [IconImage](#) | Sets the material design icon. |\n\nDetailed documentation\n----------------------\n\n### `set``Alt``Text(altText)`\n\nSets the alternative text of the URL which is used for accessibility.\n\n#### Parameters\n\n| Name | Type | Description |\n|-------------|----------|-----------------------|\n| `alt``Text` | `String` | The alternative text. |\n\n#### Return\n\n\n[IconImage](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Icon(icon)`\n\nSets the predefined icon if the URL is not set. Default is NONE.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|--------------------------------------------------|--------------------------------------------------------------------------------|\n| `icon` | [Icon](/apps-script/reference/card-service/icon) | One of the predefined [Icon](/apps-script/reference/card-service/icon) values. |\n\n#### Return\n\n\n[IconImage](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Icon``Url(url)`\n\nSets the URL of the icon if the icon is not set.\n\n#### Parameters\n\n| Name | Type | Description |\n|-------|----------|------------------------------------------------------|\n| `url` | `String` | The URL address of a hosted image to use as an icon. |\n\n#### Return\n\n\n[IconImage](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Image``Crop``Type(imageCropType)`\n\nSets the crop style for the image. The crop type options you can use for icons are `SQUARE\n` and `CIRCLE`. Default is `SQUARE`.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------------|----------------------------------------------------------------------|------------------------------------|\n| `image``Crop``Type` | [ImageCropType](/apps-script/reference/card-service/image-crop-type) | The ImageCropType option to apply. |\n\n#### Return\n\n\n[IconImage](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Material``Icon(icon)`\n\nSets the material design icon.\n\n```javascript\nconst iconImage = CardService.newIconImage().setMaterialIcon(\n CardService.newMaterialIcon().setName('search'),\n);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|-------------------------------------------------------------------|--------------------|\n| `icon` | [MaterialIcon](/apps-script/reference/card-service/material-icon) | The material icon. |\n\n#### Return\n\n\n[IconImage](#) --- This object, for chaining."]]