Before Android 4.0, you can get the width of the screen in the following way:
Displaymetrics dm = new Displaymetrics ();
Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM);
int Mscreenw = dm.widthpixels; Get width
int mscreenh = dm.heightpixels; Get high
By the above method before 4.0, the total width and total height of the screen, including the height of the status bar and the height of the navigation bar, such as a 480 * 800 device, the above method to obtain the value is 480 and 800, However, after 4.0, the above method gets the height that is removed from the height of the navigation bar, for example, if the height of the navigation bar is 48, the value of the mscreenh obtained by the above method after 4.0 is equal to 480-48 = 432.
Therefore, if you want to get the total height of the screen after 4.0, you need to use the following method:
Display display = Getwindowmanager (). Getdefaultdisplay ();
Point point = new Point ();
display.getrealsize (point);
int mscreenh = POINT.Y;
int mscreenw = Point.x;
The wide height obtained is 480 and 800.
Note: We do the car, so the size is the size of the horizontal screen.