For example, if you give a the size of a button 20px that may look great in the device that you are testing your app on, but if you run it on a different device it may not look the way you intended it to look. That's because when you set the size on pixel,it is fixed therefor in a small device if it looks good then in a bigger device it will look really small.
So, I just said that if we give px(pixel) unit, it is fixed but what happens when we give dp (density independent pixel) unit. At runtime the system handles any scaling of the dp units. One dp is equivalent to 1px in a 160dpi(dots per inch) screen, this is the baseline density.
The conversion equation of px and dp is:
px/dp = dpi/160dpi
If we have a a screen with 213dpi screen then we'll get 1dp equal to 1.3px.
px = dp*(dpi/160dpi) = dp*(213/160 ) = 1.3dp
So, this is what I know about dp. If there's any mistakes feel free to point it out but be kind :) .