How to distinguish between 480X800 and 480X854 screens in Android?

How to distinguish between 480X800 and 480X854 screens. we have the ability to put one image in the hdpi folder. In my case, the 480X800 image does not support the 480X854 image. he shows an empty space below. Any idea?

Edit: I set the image as the background. on my layout I have transparent images with margins. if I click on the image, it performs some task. but between these two screens. I can adjust the value for one. in another, the image was slightly corrected. what can i do? can you understand my problem? please, help.

+4
source share
4 answers

You can infer permission from the current current process, but you cannot get the exact permission. As far as I know, they cannot be distinguished from two "large" displays, which you can hope for, supports any size of your application.

If you display an image (and assume that the application is available for all screen sizes), just make the image the size of a larger resolution and do not let another bit be displayed. If the image file is small, you should not have a problem.

By the way, I solved the problem first by making the application layout available for the entire screen resolution and setting it for lower resolutions.

hope this helped!

+1
source

You should not distinguish between the two; you should make every effort to simply maintain screen density, not specific screen resolutions. Otherwise, you will be in a mess when devices with different screen resolutions appear. That's why we have nine shots! :)

See also this question:
What resolution should screens for Android have?

If you absolutely must distinguish between them, you can use long and notlong resource qualifiers. e.g. WVGA values-hdpi-notlong and FWVGA values-hdpi-long .
Obviously, this is not true , all the more reason for not distinguishing and creating shared resources that can handle small changes in resolution.

+4
source

Christopher, you have to make your application flexible, but if you really need screen resolution, you can use:

  Display d = ((WindowManager) activity.getSystemService (Context.WINDOW_SERVICE)). GetDefaultDisplay ();
 int width = d.getWidth ();
 int height = d.getHeight ();

From there, you can scale or zoom in / out as needed or just use 9patch. It depends on the application, but you can consider placing a 480x854 image in the res / folder and make sure that it looks right at 480x800, only with the center.

+1
source

create folder layout-hdpi-854x480

+1
source

Source: https://habr.com/ru/post/1312355/


All Articles