Dimension of a display - Android Canvas

Asked

Viewed 92 times

1

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

Physically the appliances are different (the screen of the S2 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 (height) is 800px and the width (width) 480px (in Portrait). Since S2 is bigger, I thought the values would not be equal.

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

1 answer

1


Not much of a pattern. Android can be used in tablets, smarthphones, watches, Tvs and etc. Each manufacturer adapts the system to the appliance according to the needs and proposals of the same.

What you can do is develop by focusing on the most popular dimensions and designing thinking about 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 project is pixel density.

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

Check out this link for more details.


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.