1

I'm not new to Android app development. I have already created few apps with very simple UI where I didn't have to worry about screen resolution / dpi / dp... But today I have to create a more advanced Android app with a custom UI design (very "graphic").

I want to implement a splash screen (with an image in full screen). It's difficult and tedious because with Android we have to deal with a lot of resolutions and densities.

My problem

I have no idea what size to put in every drawable folder (ldpi, mdpi, hdpi and xhdpi).

What sizes (in pixels) should i create so the splash displays nice on all screens? Concretely, what files I need to create?

Few remarks

  1. I know there are many other topics on StackOverflow (here, here or here) about Android splash screen / resolution issues. But none of these, in my opinion, gives a understandable / clear answer (I mean, with px).

  2. I have read "Supporting Multiple Screens"

  3. I'm aware of ratio between the densities:

    • ldpi (0.75x)
    • mdpi (baseline)
    • hdpi (1.5x)
    • xhdpi (2.0x)
    • xxhdpi (2.5x)
  4. I'm aware of the 9-path image solution but it's not applicable for what I want (a full screen picture).

  5. Tool like this one is helpful to converting dp in px

  6. I have decompressed many APK files to see how these applications deals with splash screen images. None use the same size, it's confusing!

  7. I do not need landscape splash screen.

  8. With a 800x1280px PNG file (in xhdpi) it OK on my Nexus 4 emulator but verticaly stretched on Galaxy S4 emulator.

Community
  • 1
  • 1
Guicara
  • 1,668
  • 2
  • 20
  • 34

2 Answers2

0

Like you already pointed out, the case you want to use as your reference frame is mdpi device. You need to make sure that you're happy with how your splash screen looks on mdpi device, and the Android will automatically re-scale your drawables for you, as long as you use .9.png (9-patch image) format and that the device has same aspect ratio.

For more information on 9-patch format, click here.

nstosic
  • 2,584
  • 1
  • 17
  • 21
0

There is no single aspect for android screen, so there is no perfect solution for showing splash screen. You just need to put your image into some layout and display it as separate activity. Take a look for ImageView and scale property: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html There is no universal solution for all cases, but try something like that: put RelativeLayout as base layout, set match_parent for both height and width put ImageView at center of it, set match_parent for width, wrap_content for height, try scale mode for getting satisfying result. You can set background drawable for the base layout to fill up margins with some plain color or gradient. Once you get the correct scalling try how it looks on smaller screens supply other resolutions to avoid excessive downsampling.

piotrpo
  • 12,398
  • 7
  • 42
  • 58