A
A
Andrei K2017-07-19 14:45:41
Android
Andrei K, 2017-07-19 14:45:41

Am I understanding dp/dip correctly in Android?

1 dp is simply 1/160 of an inch of a device's screen.
The specific number of pixels in 1 dp depends on the PPI (pixels per inch, aka DPI) of the screen.
Those. if PPI is 320, then there will be 2 pixels in 1dp (320/160).
From this we can conclude that by specifying an element size of 160dp, the actual size of the element on any screen will be 1 inch. After all, 160dp is 160 pieces of 1/160 of an inch, and this is 1 inch. And how many pixels will be in this inch depends on the PPI.
For example, an 8dp device with PPI=320 will have 16 pixels, with PPI=480 it will have 24. But the final physical dimensions of 8dp will be the same - it will always be 8/160 of an inch of the screen regardless of PPI.
Once again, the same thing: taking a ruler and starting to measure the dimensions of the elements specified in dp, the physical dimensions of the element will be approximately the same everywhere. In this case, scaling will not occur : a button that takes up half the screen on a small device will take up less space on a large screen, but the physical dimensions of these buttons will be the same.
Did I understand correctly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question