Search code examples
androidscreen-size

Android different screen size issues (Testing on Galaxy S1, S2, S3 and Note2 etc)


I'm working on a game, it's almost complete (just tweaking & testing), I have Samsung galaxy S1, so graphics works just fine on Galaxy S1 and S2, however.. tested on Samsung galaxy S3; had to create image resizer function to resize all the files when loaded, now it works just fine on that. But, I don't have all Android devices to test the graphics on different screen size. I've created different screen size devices on emulator(AVDM), tried on them, but bad result (ramsize, heap size had to be unreal to test properly).

That's a background info. Ok, let me get to the point; I haven't tested the game on bigger screen devices but tested on Samsung Galaxy S3, graphics were smaller on S3 since it loaded images from mdpi folder. So, what I'm doing with my graphics is, loading pre-resized images and I get the device's screen size and trying to resize them manually with float values to make sure the graphics is not too small nor big for current screen while the "AnyDensity=false" on manifest.xml. It's easier to do that when you actually test on the specific devices to get expected result. I've disabled the auto-resize function to fasle to avoid "OutOfMemoryError" when android resizes graphics automatically. It works, but it's hard to assume the float value when you can't predict the screen size.

I want to hear your experience on this, what do you guys suggest on such situation? How do you resize your graphics for different screen size devices to fit perfectly on the screen knowing current screen width and height values?

An example: forest_1.png width/height: 600 x 400 px on Samsung Galaxy S1 (533 x 320) screen would render perfectly, but how to predict the exact values to resize forest_1.png image for Android Note II without having the device to test? (Note II screen size is 1280 x 720 )

Any comments / suggestions would be appreciated, thanks!


Solution

  • In my opinion you will need to resize the image programmatically. Examples you can find in answers here: Image crop and resize in Android

    And this is how you get the dimensions of your device: Get screen dimensions in pixels