2
votes

Is there a simple mapping between Codename One MultiImage sizes and Android's drawable resource folders?

When importing any image into CN1 as a multi-image, the following size options are given, no matter what size the base image file is:

  • Very Low: 28x28
  • Low: 36x36
  • Medium: 48x48
  • High: 72x72
  • Very High: 96x96
  • HD: 196x196

According the Android iconography, the following relative sizes should be used when creating drawables for the different folders:

  • MDPI: 1x
  • HDPI: 1.5x
  • XHDPI: 2x
  • XXHDPI: 3x
  • XXXHDPI: 4x

This suggests the following mapping of Android dpi resources to CN1 multi-image sizes:

  • LDPI --> Low
  • MDPI --> Medium
  • HDPI --> High
  • XHDPI --> Very High
  • XXHDPI --> HD

Coming from an Android background, this seems to simplify the concept quite nicely; is this correct?


To preempt, I have watched the MultiImage video in the How Do I? section, as well as the Android Trail.

1

1 Answers

2
votes

Yes.

If you look at the AndroidImplementation source file in SVN you will see this block of code which will provide the definitive answer:

@Override
public int getDeviceDensity() {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    switch (metrics.densityDpi) {
        case DisplayMetrics.DENSITY_LOW:
            return Display.DENSITY_LOW;
        case DisplayMetrics.DENSITY_HIGH:
        case 213: // DENSITY_TV 
            return Display.DENSITY_HIGH;
        case DisplayMetrics.DENSITY_XHIGH:
            return Display.DENSITY_VERY_HIGH;
        case 480: // DisplayMetrics.DENSITY_XXHIGH
            return Display.DENSITY_HD;
        default:
            return Display.DENSITY_MEDIUM;
    }
}