Dry
Displaymetrics DM =NewDisplaymetrics (); This. Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); ScreenWidth=Dm.widthpixels; ScreenHeight=Dm.heightpixels; Density=dm.density; DENSITYDPI=dm.densitydpi; Scaleddensity=dm.scaleddensity; Displaymetrics Metrics=DM; LOG.I ("Yydcdut","metrics::d ensity="+metrics.density+", densitydpi="+metrics.densitydpi+", heightpixels="+Metrics.heightpixels+", widthpixels="+Metrics.widthpixels+", scaleddensity="+metrics.scaleddensity+", xdpi="+metrics.xdpi+", ydpi="+METRICS.YDPI);
Log Print out:
Metrics::d ensity=1.5, densitydpi=, heightpixels= 854, widthpixels= 480, scaleddensity=1.5, xdpi=239.05882, ydpi=243.72585
- Metrics.widthpixels Screen width
- Metrics.heightpixels screen Height
- metrics.density screen Density
The constructor displaymetrics does not need to pass any arguments, and after calling Getwindowmanager (), the Handle of the existing Activity is obtained, at which point the Getdefaultdisplay () method will take the wide-height dimension stored in the Dis The Playmetrics object, and the resulting width and height dimension is in pixels (Pixel), and "Pixels" refers to "absolute pixels" rather than "relative pixels".
I'm the dividing line of the king of the Land Tiger.
Android--Displaymetrics