In our android development, we often use the screen size to determine the ui or other purposes.
In some cases, incorrect values can be obtained by obtaining the width and height of the screen based on different models. (Unit differences and mobile phone manufacturers are different)
Two days ago, it was found that 800*480 was taken from a 533*320 mobile phone in the program, but some were normal. I don't know whether to pass "pixs = dips * (density/160 )"
. If you also encounter this problem, you can use the following code to solve it: (if not, I do not know)
1.
Display display = getwindowmanager (). getdefaultdisplay ();
// Int Height = display. getheight ();
// Int width = display. getwidth ();
Displaymetrics dm = new displaymetrics ();
Dm = getresources (). getdisplaymetrics (); // If the obtained height and width values are inconsistent with the actual values
Display. getmetrics (DM );
Int heightpixels = DM. heightpixels;
Int widthpixels = DM. widthpixels;
2.
Add this configuration in manifest
<Supports-screens
Android: smallscreens = "true"
Android: normalscreens = "true"
Android: largescreens = "true"
Android: resizeable = "true"
Android: anydensity = "true"/>