codenameoneandroid-resourcesxcassetpixel-density

CodenameOne - Using 1x 2x 3x images of XCode Assets.Casset catalog in CN1 project


My CodenameOne app needs customized icons for some buttons. Images have to be used.

The iOS version of my app was duly provided of those images in 1x 2x 3x formats.

It seems that the multi-image system of CN1 would beneficiate of the image resources of the Android version of my app.

Indeed XCode 1x, 2x, 3x images could lead to strange assignments of "the closest alternative" as it reads in the CN1 dev guide, I think.

Table 4. Densities
Constant
Density
Example Device
Display.DENSITY_VERY_LOW
~ 88 ppi
Display.DENSITY_LOW
~ 120 ppi
Android ldpi devices
Display.DENSITY_MEDIUM
~ 160 ppi
iPhone 3GS, iPad, Android mdpi devices
Display.DENSITY_HIGH
~ 240 ppi
Android hdpi devices
Display.DENSITY_VERY_HIGH
~ 320 ppi
iPhone 4, iPad Air 2, Android xhdpi devices
Display.DENSITY_HD
~ 540 ppi
iPhone 6+, Android xxhdpi devices
Display.DENSITY_560
~ 750 ppi
Android xxxhdpi devices
Density.DENSITY_2HD
~ 1000 ppi
Density.DENSITY_4K
~ 1250ppi

As you can see the table above is compatible with the Android resources scheme.

But

in my Android project I have not images, but there are xml drawables instead. These drawables where converted from SVG drawables, courtesy of a simple and straightforward import function in Android-Studio.

So I am asking here if there is a safe way to include the Assets.casset image resources of the XCode project into the CN1 images resources. They are provided as 1x 2x 3x images, and they have to end up being assigned to the right iOS device, without wrong yet "closest alternative".

Is this possible?


Solution

  • We have multi-image that works in a way similar to androids DPI level. They don't use the iOS convention since we support more device resolutions than iOS. This works both in the CSS and designer. See the developer guide on multi-image for more details.