Skip to content

Conversation

fontlos
Copy link
Contributor

@fontlos fontlos commented Apr 30, 2025

When building an APK, if an icon is specified in the configuration, it will generate *dpi variants to override the default Android icon. For simple SVG files, it additionally generates Android VectorDrawable XML for anydpi. Refs #3685

The icon file is specified in the following configuration:

# Dioxus.toml
[bundle]
icon = ["path/to/icon"]

However, there are two issues:

First, I'm not sure why the icon is defined as Vec<String>. I couldn't find any usage of this field in the project as a reference, so I default to using the first element as the icon.

Second, Android appears to apply some scaling to the foreground of Android VectorDrawable XML, causing the actual icon to be enlarged and cropped. This requires adding some margin when creating the SVG. Additionally, currently the same icon file is used for both foreground and background, and only SVGs composed of simple paths are supported.

When building an APK, if an icon is specified in the configuration, it will generate `*dpi` variants to override the default Android icon. For simple SVG files, it additionally generates Android VectorDrawable XML for `anydpi`.

The icon file is specified in the following configuration:

```toml
# Dioxus.toml
[bundle]
icon = ["path/to/icon"]
```

However, there are two issues:

First, I'm not sure why the icon is defined as `Vec<String>`. I couldn't find any usage of this field in the project as a reference, so I default to using the first element as the icon.

Second, Android appears to apply some scaling to the foreground of Android VectorDrawable XML, causing the actual icon to be enlarged and cropped. This requires adding some margin when creating the SVG. Additionally, currently the same icon file is used for both foreground and background, and only SVGs composed of simple paths are supported.
@fontlos fontlos requested a review from a team as a code owner April 30, 2025 06:32
@jkelleyrtp jkelleyrtp added this to the 0.7.0 milestone Jul 1, 2025
@brisk0
Copy link

brisk0 commented Sep 4, 2025

Hi Fontlos, regarding your Vec<string> query:

icon - Paths to icon files to be used in the bundle. Icon files must be square and 16, 24, 32, 64, or 256 pixels in size. PNG icons must have a 32 bit depth in the RGBA format. If you use a .icns file is must fit this format. The icons must include a .icns icon for macOS, .ico for Windows and .png for Linux.

https://dioxuslabs.com/learn/0.6/CLI/configure#bundle

I read this part of the docs as implying that icon is defined as a Vec<String> in part to accommodate different format requirements for different platforms.

Based on this the behaviour I would expect from Dioxus would be to search for the first svg in the list, or to have an order of preferences (e.g. .xml > .svg > big png > small png).

I think this describes the scaling, essentially the final size is 75% of the total size

https://developer.android.com/distribute/google-play/resources/icon-design-specifications#legacy_mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants