Android and android Official Website
Pixel density and screen adaptation
Address: http://blog.csdn.net/caroline_wendy
The diversity of Android devices often requires adaptation based on different screens to obtain hardwareScreen pixels and DensityMethod:
DisplayMetrics dm = new DisplayMetrics (); getWindowManager (). getdefadisplay display (). getMetrics (dm); int widthPixels = dm. widthPixels; int heightPixels = dm. heightPixels; float density = dm. density; float dpi = dm. densityDpi; float screenWidth = widthPixels * density; float screenHeight = heightPixels * density; Log. d (TAG, "screen width:" + screenWidth); Log. d (TAG, "screen height:" + screenHeight); Log. d (TAG, "screen density:" + density); Log. d (TAG, "screen DPI:" + dpi );
TV)The adaptation of the client is special, and the differences between large, medium, and small screens are large.
Smallest Screen WidthTo adapt, select the minimum value between the width and height: for example, the minimum side is close to 1080, you can adapt (
Greater than or equalAdaptation value 1080 ):
Values-sw1080dp