Home android What is 1 px

What is 1 px

Author

Date

Category

There is a picture with a 100px discharge. What value should be set to DP so that on all devices there is an indent, as in the original? As for the picture, it is clear, you need to throw in folders, and about sizes and indents how to be?


Answer 1, Authority 100%

Remember:

Everything is very simple, imagine the square 1x1cm (according to the usual ruler, draw for clarity), so the pixels are placed in this square, and they can fit 100×100 , 1000×1000 , 700×700 or even so 777×888 depending on the real size of the pixel (depends on the matrix used)! All this is called “pixel density.”

to expand the horizons:

pixel itself, in fact, is a platform,
on which there are 3
subpixel, they have RGB colors, but in
Depending on the screen type Subpixels
can be located differently and \ or
Have a different shape, and even in color they
may not be pure RGB …

And these densities +100500. In Androyd, all of these +100500 densities are approximately averaged in several “density” (LDPI, MDPI, HDPI, etc.). Due to the fact that the matrices of the screens are a huge set, then you can not count on a real fixed indent.


And there are different sizes of screens as
then mobile phones, tablets, monitors and
etc.

And there are still different forms of screens,
Square, rectangular, round …


Conclusion:

Pine non-sinkers, so that they did rubber layouts …

UPD for @andro

There are 3 measurement systems

  1. mm “or” cm “
    Fixed standard (ruler)
  2. “px” pixels – essentially a unit of measure
    digital graphic data but she
    does not have bindings to “mm” or “cm”
  3. “dp” invented virtual system
    Measurements whose purpose to give
    programmer something mean between
    “PX” and “mm”. The essence of the idea is that
    “DP” on a specific device
    multiplied by “DENSITY” (it
    Manufacturers are recorded in
    firmware). In the end, we get albeit
    not “strictly accurate” size, but still
    “close approximate”!

Therefore, in all the phages across the Android and they say that the dimensions need to be specified in “DP”, but the problem is that little is explained “why.”


Answer 2

For a start, go through the documentation screen support . Pixels are not recommended to use, because On different screens the application will look different.
If you look at the RES folder, we have several resource folders for different permissions. Each of these folders has its own screen density (screen density coefficient), which is responsible for the extent of scalability.

  • Low (LDPI) = 0.75
  • medium (mdpi) = 1
  • tv (TVDPI) = 1.33
  • high (HDPI) = 1.5
  • Extra High (XHDPI) = 2

i.e. On MDPI – 1px = 1dp, on XHDPI – 2PX = 1DP, etc.

Here is another useful link to read Tyk .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions