Dimension of a display - Android Canvas

1

I'm doing tests with an image on Android using the Canvas class. I am using a Samsung Galaxy S3 Mini and a Samsung Galaxy S2.

Physically the devices are different (the S2 screen is larger), but the returns of the methods below are the same:

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
width = size.x;
height = size.y;

For both devices, the height is 800px and the width is 480px (in portrait). Since S2 is larger, I thought the values would not be the same.

Is there any standardization for the display size of smartphones? Is most of this pattern, 800 by 480 (or at least will most use this ratio)?

    
asked by anonymous 20.01.2015 / 19:41

1 answer

1

There is no pattern. Android can be used on tablets, smarthphones, watches, TVs and etc. Each manufacturer adapts the system to the device according to its needs and proposals.

What you can do is develop by focusing on the most popular dimensions and designing with dp instead of px .

In your case, you have tested on two devices that have screens of different physical dimensions, but have equal resolutions. So what you should consider in your design is the pixel density.

 DisplayMetrics metrics = new DisplayMetrics();
 getWindowManager().getDefaultDisplay().getMetrics(metrics);
 // Verifique metrics.

Check out this link for more details.

On the use of image, you may have to make different versions available for each pixel density (ldpi, mdpi, hdpi, xhdpi, xxhdpi) in your apk.

    
20.01.2015 / 20:47