Danstern
Danstern

Reputation: 147

calculus of dp and actual dp doesn't match

i calculated the dp of a device (smallest width), in particular a google pixel 3 (440dpi 1080x2160), using the formula:

px = dp*(dpi/160)

the result was 392.72, so i created the file animator-sw390dp-xxhdpi to handle it, but it turns out that the file isn't applied, instead of it, the file animator-sw320dp-xxhdpi is applied. Using try and error approach i found out that the "true" dp value is 360, in that value the correct file is applied, a hypothetical animator-sw360dp-xxhdpi. if i change 360 to 361, i mean animator-sw361dp-xxhdpi, it apply the 320 file again (or 360 if it exists).

So, where is the mistake in the calculus? how can i really calculate the dp of a device given its resolution? and more important how can i know what file will be applied to a file given its smallest width and density without testing files dp by dp as i did?

Upvotes: 0

Views: 92

Answers (0)

Related Questions