How to distinguish a layout for a screen resolution of 480 * 800 and 480 * 854 in Android?

In one application, I need to make sure that the user interface components are placed in the correct position on all screen resolution devices. I went through the support of a few screen resolution tips on the Android developers site. Based on this, it seems to me that I may have to create separate layout files for small, conventional and large screen devices. Now the problem is that even on large screens there are different resolutions, such as 480 * 800 and 480 * 854. On the screen, the components are a bit lost. I set the top edge to 100 dip, then for 480 * 800 it looks right, but for 480 * 854 it is a little laid out.

Can someone let me know how to handle this now?

+4
source share
2 answers

both resolutions are considered in the layout length, so you need to set the layout according to the height and width of the device manually.

In my opinion, this is the best solution. I applied the same solution for my application.

Example

DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); height = dm.heightPixels; width = dm.widthPixels; if (height == 854 || width == 480) { // Your view } else { // Your VIew } 

You must check the specified condition in the onCreate () method.

+3
source

Between WVGA854 and WVGA800 it should be possible to distinguish between:

Res / hood-HDI-long / RES / hood-HDI-notlong /

but I would definitely recommend that you design layouts so that it is strong enough to use one set of layouts for these two screens. There will be too much maintenance / testing work; you cannot create one layout in this case.

-1
source

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


All Articles