We usually have this requirement when developing the UI. The following section shows the size of the screen.CodeYou can get the screen size on the Android platform. The code is as follows:
1. Display display = getwindowmanager (). getdefadisplay display ();
2. log. I ("View", "height:" + display. getheight ());
3. log. I ("View", "width:" + display. getwidth ());
Display display = getwindowmanager (). getdefaultdisplay ();
Log. I ("View", "height:" + display. getheight ());
Log. I ("View", "width:" + display. getwidth ());
You can also save the display size information to a displaymetrics object. The Code is as follows:
1. displaymetrics = new displaydisplaymetrics ();
2. getwindowmanager (). getdefadisplay display (). getmetrics (displaymetrics );
3. log. I ("View", "height" + displaymetrics. heightpixels );
4. log. I ("View", "width" + displaymetrics. widthpixels );