NR: General comment - I think when detailing each platform we should be very specific about the image sizes that we need to generate for splash, icon, etc. Remember that this will form the spec for what we're going to be using resizitizer for - if you're calling resizitizer, what output dimensions are you going to be requesting.
This file will discuss the guidelines for Splash screens and App icons across Android and iOS platforms. Then it will discuss the Resizetizer and ideas on how to make the work of creating those components easier for developers.
Splash Screen
Android
From android docs the elements that compose the Splash Screen should be defined by XML resources in the Android Manifest. And these elements are:
- App icon
- Icon background
- Window background
And the Splash screen dimensions should be:
- Branded image: 200x80 dp
- App icon with an icon background: 240x240 dp, and fit within a circle of 160 dp in diameter
- App icon without an icon background: 288x288 dp, and fit within a circle of 192 dp in diameter
For Android <12 we need to include a splashscreen.xml file that defines the layout of the splash screen for legacy support. If we still support old targets.
Android also supports animated splash screens, but you need to define those in Animated Vector Drawable (AVD) XML format. I believe it's out of the scope right now and can be investigated in the future as an enhancement.
iOS
Apple doesn't have a requirement for Splash Screen as Android does, in general, is just a page that fills the entire device screen and you can set whatever you want there. The guidelines say to be a representation of the App's first-page layout, but normally apps use to present the same splash screen as Android, with a company icon.
WPF
From docs the Splash Screen should be an image file using a format that's supported by Windows Imaging Component, like BMP, GIF, JPEG, PNG, or TIFF format.
But there's no specification about the size.
App Icon
Android
From android docs the icon can assume different shapes, visual effects, and user theming. It's called Adaptive icons
. The icon design requirements are:
- All layers must be sized at 108 x 108 dp.
- The icons should be clean edges; the layers must not have masks or background shadows around the outline of the icon.
- The logo must be at least 48 x 48 dp; it must not exceed 72 x 72 dp because the inner 72 x 72 dp of the icon appears within the masked viewport.
- The outer 18 dp on each of the four sides of the layers are reserved for masking and to create visual effects such as parallax or pulsing.
And the adaptive icon is represented by XML.
iOS
From apple docs the app you can see the guideline changes across devices, so here the focus will be on iOS and iPadOS.
From the Specifications
section, the icon should follow these guidelines:
- One single layer
- No transparency
- Asset shape should be square
- Should provide different sizes (documented in the Specification section)
The assets are represented by a JSON file, containing the name and location of each icon size.
Linux
From gnome docs the app icons are drawn in canvas with 128x128 area, but the space shouldn't be filled. In order to generate the icons, we must follow these guidelines:
- Provide a icon with the sizes of 32x32, 64x64, and 128x128 pixels;
- A Symbolic App Icon, that is simpler than the icon provided in the last item
From this source the icon can be .svg
, so we don't need to care about sizing, the OS will do that for us, or .png
in this case we need to provide different files using the required sizes. From the PDF file, chapter 3 section 1.
If you use bitmap icons, you’ll need to provide several files with different resolutions. The most important one for applications and file types is a 48 × 48 pixel square, and 16, 32 and 64 pixel square shapes are also common
WPF
For WPF we've a large set of icon sizes, but focusing on application icons we should provide the following sizes, for the current mode:
- 16x16
- 32x32
- 48x48
- 256x256
And the following sizes for the Classic mode:
- 16x16
- 24x24
- 32x32
- 48x48
- 64x64
All apps should be of type .ico
.
Resizetizer Spec
Today we can use the MauiResizetizer on Uno images and that pretty much works, the splash screen and icons partially work, probably some adjustments on our end will make it compatible.
So the first spec is to use the Resizetizer NuGet package, today the highest version that works at Uno is 6.0.101-preview.11.2349
. Newer versions didn't compile, maybe Uno uses an old .net6 version? Not sure yet.
Specification in general
The assets can live inside the Shared
project, inside the assets folder, and then get into the right place through MSBuild tasks. We can split the type using folders inside the asset, like Images, AppIcon, SplashScreen, Fonts, etc
and use wild cards to control their meaning.
We also need an MSBuild property for those assets, so I'll use the Resizetizer as a reference.
For Images we will have something like:
<MauiImage Include="Assets/Images/myImg.svg BaseSize="100x100" TintColor="#FF0000" />
- Include: The path of the asset, it can also support wild cards, something like
Assets/Images/*
- BaseSize: The size that should be used as a base to generate the final assets in the respective resolution
- TintColor: Customizes the Image color.
For icons:
<MauiIcon Include="Assets\AppIcon\appicon.svg" ForegroundFile="Assets\AppIcon\appiconfg.svg" Color="#512BD4" />
- Include: The path of the background asset
- Foreground: The path of the foreground asset
- Color: Customizes the background color.
For Splash screen:
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
- Include: The path of the asset that represents the splash screen
- Color: Customizes the background color.
Image asset resize
The asset resizing scales based on the BaseSize property value, if a value isn't provided we can use the default asset size. Let's use iOS as a sample since it's simple. For iOS we have 3 sizes, there's the normal size then @2x
and @3x
, that's two times the base size and 3 times the base size, respectively. So the tooling should grab the BaseSize and generate assets that are x1, x2, and x3 its value.
For Android, it will work the same, but we've more scales to work.
I can see two options for Uno to add this feature as a public API.
Use the .NET MAUI Resizetizer
Using the risizetizer we can see better what we need to change, in our template and build tasks to support it and work with the .NET MAUI team to add features and hooks that can be used by Uno projects. Like adding support, out of the box, for wasm, Linux, and other targets.
Create our own MSBuild tasks
If we go on this path, I suggest using a pattern of no naming the MSBuild properties, following a convention of having Uno
as a prefix, something like:
- UnoSplashScreen
- UnoImage
- UnoIcon
And we can keep the same MSBuild properties, with different names if needed.