When it comes to pixel density, let's figure out what pixel density is, which literally means the number of pixels in a certain size area on the phone screen. In Android development,
We typically use a unit of pixel density per inch (dpi) to represent the pixel density of your phone's screen, and the DPI conversion method is as follows:
Step 1: Calculate the bevel pixel length of the phone screen:
Step 2: Use the screen bevel pixel length to remove the screen size on the phone to get DPI
So, with such a formula we can easily understand the DPI, is actually the angle of the pixel length and the size of the phone screen a ratio, and we currently each Android phone
is to differentiate the pixel density of the phone screen by such a DPI value.
In Android generally speaking mobile phone screen per inch pixel density values are divided into: 0~120dpi~160dpi~240dpi~320dpi~480dpi~640dpi, such as several intervals, respectively, ldpi, MDPI, hdpi, xhdpi, xxhdpi, Xxxhdpi such a few words to mark, these words believe that the students in the drawable resources have seen, By putting the corresponding DPI drawable resource into the corresponding drawable directory, you can achieve drawable resources that display different pixel densities on different pixel density screens.
On the other hand, in layout resources, DP units are automatically converted to corresponding PX values based on the current screen pixel density, so we generally require that you use DP as the unit of length in layout.
Android screen pixel density adaptation detailed