سؤال

I am creating some background images that will cover the "entire" screen of the phone/tablet screen for my app. These images are for the Splash Screen. Basically, my application must support to Phones and Tablets.

I created a huge image which is 2560 x 1600, now time to resize it. But the case is, I am stuck here. What are the screen sizes for mdpi, hdpi, xhdpi, xxhdpi ? These are the screen sizes from phone to tablet right? I need these sizes in pixel values.

I have already visited to the android developer links like supporting multiple screens, but I did not find anything good from them.

Please help me to resize my images by providing the correct screen values in pixels.

هل كانت مفيدة؟

المحلول

Hdpi, xhdpi, etc. are not screen sizes, they are screen pixel densities. If you want to adjust your image according to screen sizes, you should use small/medium/large/xlarge. (And combine it with hdpi/xhdpi/... for sharp and accurate results :))

You can always use some most common resolutions, like HD, fullHD, 800x480 etc. But you have a bigger problem - differences in aspect ratio. Newer devices tend to use 16:9 aspect ratio, but older models with 800x480 screens are different, so you should consider some padding/cropping to ensure image is not stretched, and just then worry about resolution.

Good luck with that :)

Edit: You can create your own resource folders, you can even use multiple modifiers.

http://developer.android.com/guide/topics/resources/localization.html

Just create folder 'drawable-small-hdpi' or whatever and it will work :)

You can also use other modifiers, f.e. drawable-de-small should load specified drawables only on "german speaking" devices with small displays.

About image sizes: documentation(the article you are linking) states:

  • xlarge screens are at least 960dp x 720dp

  • large screens are at least 640dp x 480dp

  • normal screens are at least 470dp x 320dp

  • small screens are at least 426dp x 320dp

So you if you want good compatibility, you go like this(in pixels):

  • small-mdpi = 426x320

  • small-hdpi = 639x480

  • small-xhdpi = 852x640

  • normal-mdpi = 470x320

  • normal-hdpi = ....

    ......

  • xlarge-hpdi = ....

  • xlarge-xhdpi = 1920x1440

Just remember that 1 dp in mdpi is 1px, in hdpi it is 1.5px, xhdpi is 2px and xxhdpi is 3px.

In practice, you really don't see many xxhdpi devices with small or even normal screen, so you can omit some extremes. If you don't care about some stretching here and there on smaller phones, you can even completely ommit the small option and rely on the match_parent attribute to fit the image.

But you still have to design carefully because these are just minimum sizes.

Also consider phones with hardware buttons and software buttons - with hardware buttons and same screen, you get more space for your app, so, again, different aspect ratio!

From my experience, I would recommend splitting your splash screen in elements that must at all times remail "good looking", like logo. And then define some background that can stretch a bit here and there. So that you can set the background to match_parent and always cover whole screen and "logos" to wrap_content or fixed size in dp so their aspect ratio won't change and pixel size can be easily calculated.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top