First, introduce the DP and SP.
DP is also dip. This is basically similar to SP. You can use a DP or SP if you set properties that represent length, height, and so on. However, if you set the font, you need to use the SP.
The DP is not density-independent, and the SP is not related to scale, except for density. If the screen density is 160, then the DP and SP and PX are the same.
1dp=1sp=1px
Second, introduce the PX
But if you use PX as the unit, if the screen size is the same (assuming 3.2 inches), the screen density becomes 320.
So the original width of the TextView is set to 160px, in the density of 320 of the 3.2-inch screen is more than the density of 160 of the 3.2-inch screen to see the half-short.
But if it is set to 160DP or 160SP. The Width property value is automatically set to 320px. That means 160 * 320/160.
320/160 of these are called density scale factors. that is, if you use the DP and SP, the system will automatically convert based on the change in screen density. Let's see what other units mean. PX: Represents the actual pixel of the screen.
For example, the 320*480 screen has 320 pixels in the landscape and 480 pixels in the portrait. In: represents inches, which is the physical size of the screen. Equal to 2.54 centimeters per inch.
For example, describe the size of a mobile phone screen, often said, 3.2 (English), 3.5 (English), 4 (English) inch refers to this unit.
These dimensions are the diagonal length of the screen. If the phone's screen is 3.2 inches, it indicates the phone's screen (viewable area)
The diagonal length is 3.2*2.54 = 8.128 centimeters. Readers can measure their own phone screen to see if the actual size is the same.
welcome everyone to join my QQ group: 454430053
Length units in Android, detailed