Search code examples
androidresolutiondpi

How to calculate the smallestWidth on android?


Resolution is 1920*1080 and the actual size is 5 inch.

How to calculate the smallestWidth on android ?

Which the res folder should be used on the handset,including drawable,values and layout folder?


Solution

  • Firstly, i get the dpi:

    dpi = root(1920*1920+1080*1080)/5 = 440.5

    Then I use the formula to get the samllestWidth :

    samllestWidth=1080/(dpi/160)=1080/(440.5/160) = 392.2

    So the smallestWidth is 393dp

    But if the manufacturer set the dpi to 480 , the smallestWidth will be :

    smallestWidth = 1080/(480/160) = 360dp