What screen resolution should I consider when developing an Android application?

I searched for a while to find out what screen resolution I should consider before embarking on an Android app.

I found these things:

xlarge screens at least 960dp x 720dp

large screens of at least 640dp x 480dp

normal screens at least 470dp x 320dp

small screens at least 426dp x 320dp

What devices should be considered when developing Android applications?

but actually this is not what I wanted.

that I wanted to know if I should develop an application for each of these permissions or take into account only the most commonly used permission

or

if I don't use any hardcoded values ​​for width, height and margin, etc., I never need to worry about screen resolutions

or

How good is it: find the width and height of the device using the display metrics and create all the views according to these Dynamic values?

+6
source share
4 answers

Do I have to develop an application for each of these permissions or take into account the most commonly used solutions.

You must make sure that your application works correctly on all screens, and not just on the most popular one. I would start from the bottom up ... first make sure that it works correctly on small / regular screens (and you make sure that it works on all screens). Then you can optimize your layouts for tablets with multi-panel layouts, etc.

Unless I use hardcoded values ​​for width, height and margin, etc., I never need to worry about screen resolutions.

Not sure what you're trying to say here, but you should always be careful about different screen resolutions using dp (density independent pixels) instead of px .

Find the width and height of the device using the display metrics and dynamically create all the views according to these values?

This should be the last resort. In most cases, your layouts will not be so complicated, although they are not needed. You will use wrap_content and match_parent lot of time to set the width / height, and often you will use a RelativeLayout to place the views relative to each other. You really need to measure the width / height of the views if you find it absolutely necessary.

+7
source

IMHO, you should always code the application in such a way that every device is supported. From the launch icon, which is described in detail here (different resolution for different screen sizes): http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html into the layout of your application, which should be designed so that everything is placed relatively screen size (using attributes such as match_parent and wrap_content).

You can try to encode it so that the views are created dynamically after detecting the screen size, but I think it will be easier and more efficient to make your first idea!

+4
source

The best option is to dynamically increase the width and height of the screen using simple height and width options.

 DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int height = displaymetrics.heightPixels; int wwidth = displaymetrics.widthPixels; 

another option is to create it for a device with the maximum width and height of the screen, and then mathematically process it for the appropriate screen size.

+3
source

Well, design is recommended for all sizes. But I know a lot of overhead.

So what you can do is design for the largest device you are aiming at and configure the devices based on their size. Do not use hard-coded values. Use wrap_content or fill_parent .

And yes, dynamically adjusting the images is a good idea, although it requires more coding on your side. This is the technique that I use.

+2
source

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


All Articles