Deal with the different screen sizes when retrieving picture from server to Android devices

1.4k Views Asked by At

I am working on an app whose splashscreen would be handled dynamically. Thing is, there is only one background image we can upload on the server, so on the server side I need to prepare this image to fit with the different kinds of devices there are.

I can't seem to find an accurate list of image resolutions (in px) that would cover more or less all the Android devices (resolution generally seem very low compared to what I have for iPhones for example, and usually don't include tablets).

Does anyone have this information so I could set the server to generate different resolutions from the unique picture I upload and then I could retrieve whatever fits with the device I am currently working on (by passing relevant information about the size)?

Thanks in advance.

2

There are 2 best solutions below

0
On

From your side is it possible ?

1.) first get the device size and make the server call , pass device type/size/flag or some identifier.

2.) pass some identifier parameter from your side to server side which recognize your image according to the device.

3.) server side side set same more than one image.

4.) set the response according your device size.

0
On

i think you only need 1 image, the largest resolution your app would possibly show,
and then you can specify the ImageView's layout_width and layout_height to your preferrable size in dp (or i think it's fill_parent if it's a splash)
i think it will resize the image automatically

how do you fetch the image background by the way?
i've done the same thing, i put the largest resolution in server, fetch the image using UrlImageViewHelper and it resizes automatically just fine, in different layouts

so there is only one image you'll use for the splashscreen background? i think the better approach is to just put the image in your package,
9patch image would do good to support different screensizes


or, if you really insist to fetch it from the server (you have the same image with different resolutions),
-specify your preferable width and height programatically according to the screensize
-round it (because various screensizes might generate different sizes in pixel), and add the width and height to the image_url string (
(ex: http://myServer.com/images/myImage300x600.jpg, http://myServer.com/images/myImage500x800.jpg , etc)
-make sure your server have the desired image by name

but because of the variety of device screensizes, i think the image still have to resize itself so it can fill the container