目录

Generating a Single-Layer Icon

With the Image Asset feature on DevEco Studio, you can generate device- and screen density–specific icons and easily locate these icons in the directories. Two types of icons can be generated with Image Asset:

  • Currently, the Image Asset feature can be used to generate single-layer and rounded icons for phone, tablet, and 2-in-1 device apps.
  • If you use Image Asset in a module-level directory (entry or other modules), icons of the Icon and start window icon type are generated. These can be used to configure the icon and startWindowIcon fields in the module.json5 file. If you use Image Asset in a project-level directory (such as AppScope), only an icon of the Icon type is generated, which can be used to configure the icon field in the app.json5 file.
  1. Right-click a module or file in the project directory and choose New > Image Asset from the shortcut menu to access the icon configuration page.

  2. Follow the onscreen instructions to set the fields.

    • Device: type of device on which the icon takes effect.
    • Icon Type: icon type.
    • Name: icon name. The name can contain a maximum of 128 characters, including letters, digits, and underscores (_).
    • Foreground Layer: foreground of the icon. It includes the following options:
      • Path: path to the foreground image. To ensure the icon clarity, use images with the size of 1024 px × 1024 px.
      • Trim: whether to adjust the spacing between the icon image and the borders and to remove the redundant transparent area around the image.
      • Resize: scale factor of the image.

    • Background Layer: background of the icon. It includes the following options:
      • Asset Type: type of the background. Available options are Color and Image.
      • Color: color of the background.
      • Path: path to the background image. To ensure the icon clarity, use images with the size of 1024 px × 1024 px.
      • Trim: whether to adjust the spacing between the icon image and the borders and to remove the redundant transparent area around the image.
      • Resize: scale factor of the image.

  3. Click Next to confirm the save path and size information. By default, the icon is saved to the resources directory. Once you have confirmed the settings, click Finish to generate the icon.

    icon.png is the icon displayed on the home screen, and icon_start window.png is the icon displayed on the splash screen. Size specifies the icon dimensions. The correspondence between each size designation and its target device DPI range is as follows:
    • sdpi: small-scale dots per inch (SDPI), applicable for devices with a DPI range of (0, 120].
    • mdpi: medium-scale dots per inch (MDPI), applicable for devices with a DPI range of (120, 160].
    • ldpi: large-scale dots per inch (LDPI), applicable for devices with a DPI range of (160, 240].
    • xldpi: extra-large-scale dots per inch (XLDPI), applicable for devices with a DPI range of (240, 320].
    • xxldpi: extra-extra-large-scale dots per inch (XXLDPI), applicable for devices with a DPI range of (320, 480].
    • xxxldpi: extra-extra-extra-large-scale dots per inch (XXXLDPI), applicable for devices with a DPI range of (480, 640].

  4. To use the new icon as the app icon displayed on the home screen or Settings screen, set the icon field in the module.json5 file to the new icon name. To use the new icon as the icon for the startup screen, set the startWindowIcon field in the same file to the new icon name.

    • Once the preceding fields are updated, the system will preferentially search for resources from the matching qualifier directories, namely, the multi-density icon files generated in step 3, based on the current device state. For details, see Matching Resources.
    • If the icon field is not configured in the module.json5 file, the system uses the icon configured in the icon field in the app.json5 file.