JavaCode Import Android. util. displaymetrics; Private displaymetrics DM; // container with screen resolution Dm = new displaymetrics (); This. getwindowmanager (). getdefadisplay display (). getmetrics (displaymetrics ); Int width = DM. widthpixels; Int Height = DM. heightpixels; Bytes ----------------------------------------------------------------------------------------------------------------------------
display = getwindowmanager (). getdefadisplay display (); |
Int width = display. getwidth (); Int Height = display. getheight (); |
The screen size obtained above refers to the size of the entire touch screen. The canvas that can be painted is only its sub-area. That is to say, the (0, 0) Point of canvas is not the (0, 0) Point of DM, but the coordinate origin point is obtained after the information bar above the screen is removed. Of course, it means that you have not set full screen. |