--- license: > Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. title: Customize app icons toc_title: Customize icons description: Learn how to customize icons for your Cordova application. --- # Customize Icons This section shows how to configure an application's icon for various platforms. Documentation about splash screen images can be found in the Cordova-Plugin-Splashscreen documentation [Splashscreen plugin docs][splashscreen_plugin]. ## Configuring Icons in the CLI When working in the CLI you can define application icon(s) via the `` element (`config.xml`). If you do not specify an icon, the Apache Cordova logo is used. ```xml ``` Attributes | Description --------------|-------------------------------------------------------------------------------- src | *Required*
Location of the image file, relative to your project directory. platform | *Optional*
Target platform width | *Optional*
Icon width in pixels height | *Optional*
Icon height in pixels target | *Optional*
==Windows==
Destination filename for the image file and all its MRT companions The following configuration can be used to define a single default icon which will be used for all platforms. ```xml ``` For each platform, you can also define a pixel-perfect icon set to fit different screen resolutions. ## Android On Android, instead of using a single image for an icon, you can use two images (background and foreground) to create an **Adaptive Icon**. Attributes | Description --------------|-------------------------------------------------------------------------------- background | *Required for Adaptive*
Location of the image (png or vector) relative to your project directory, or color reference foreground | *Required for Adaptive*
Location of the image (png or vector) relative to your project directory, or color reference density | *Optional*
Specified icon density ### Adaptive Icons To use the adaptive icons the `background` and `foreground` attributes must be defined in place of the `src` attribute. The `src` attribute is not used for adaptive icons. #### Adaptive Icon with Images: ```xml ``` **Note:** In this example, the foreground image will also be used as the fallback icon for Android devices that do not support the adaptive icons. The fallback icon can be overridden by setting the src attribute. #### Adaptive Icon with Vectors: ```xml ``` **Note:** In this example, the src attribute must be defined when then foreground attribute is defined with a vector or color. #### Adaptive Icon with Colors: Create a `res/values/colors.xml` resource file in your project directory to store the app's color definitions. ```xml #FF0000 ``` In the `config.xml`, we will add `resource-file` to copy the `colors.xml` into the approprate location so that the colors are available during build time. ```xml ``` ### Standard Icons ```xml ``` ### See Also - [Android icon guide](https://www.google.com/design/spec/style/icons.html) - [Android - Supporting multiple screens](http://developer.android.com/guide/practices/screens_support.html) ## Browser Icons are not applicable to the Browser platform. ## iOS ```xml ``` ### See Also - [App Icons on iPad and iPhone](https://developer.apple.com/library/content/qa/qa1686/_index.html) ## Windows For Windows the recommended approach to define application icons is to use the `target` attribute. ```xml ``` where `src` is the path to the icon which needs to be added. The Windows platform handles MRT icons automatically, so if you specify `src="res/windows/storelogo.png"` the following files will be copied into the application's `images` folder: `res/windows/storelogo.scale-100.png`, `res/windows/storelogo.scale-200.png`, etc. TODO Define what MRT is. The `target` attribute specifies the base name for the resultant icons. For every icon file, its destination filename is calculated as `target + '.' + MRT_qualifiers + extension(src)`. For the icons to display properly in the application, every `target` value should be one of the icon filenames defined in the application's `.appxmanifest` file. Summarizing the above... using the `target` attribute it is possible to: * define a group of icons for different device scale factors using a single `` element, for example: ```xml ``` which is equivalent to the following lines: ```xml ``` * define icons with scale factors other than `scale-100` and `scale-240` (and any other MRT qualifiers) Although it is not recommended, it is also possible to define icons using the `width` and `height` attributes: ```xml ``` ### See Also: - [Windows 10 platform guidelines for icons](https://msdn.microsoft.com/en-us/library/windows/apps/mt412102.aspx). - [Windows 8.1 tiles and icons sizes](https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh781198.aspx) [splashscreen_plugin]: ../reference/cordova-plugin-splashscreen/ ## Electron ### Customizing the Application's Icon Customized icon(s) can be declared with the `` element(s) in the `config.xml` file. There are two types of icons that can be defined, the application icon and the package installer icon. These icons should be defined in the Electron's platform node ``. One icon can be used for the application and installer, but this icon should be at least **512x512** pixels to work across all operating systems. _Notice: If a customized icon is not provided, the Apache Cordova default icons are used._ _Notice: macOS does not display custom icons when using `cordova run`. It defaults to the Electron's icon._ ```xml ``` You can supply unique icons for the application and installer by setting the `target` attribute. As mentioned above, the installer image should be **512x512** pixels to work across all platforms. ```xml ``` For devices that support high-DPI resolutions, such as Apple's Retina display, you can create a set of images with the same base filename but suffix with its multiplier. For example, if the base image's filename `icon.png` and is the standard resolution, then `icon@2x.png` will be treated as a high-resolution image that with a DPI doubled from the base. - icon.png (256px x 256px) - icon@2x.png (512px x 512px) If you want to support displays with different DPI densities at the same time, you can put images with different sizes in the same folder and use the filename without DPI suffixes. For example: ```xml ```