my company recently got imgIX but im not sure how to use the dpr .
I mean its straight forward the actual implementation but how do i know which dpr value to use to match android density. docs say that dpr goes from 1 to 8. Android has ldpi, mdpi ... xxxxhdpi. so how can i match these up ? Also, its so hard to believe they dont have a android documentation section to show usage in android given the different densities.
Reading the imgix docs about sourcesets .. so i ended up with the following scheme:
i created two integer files in values resouce directory to store the dpr values.
so like this:
*
//etc for ALL screen densities as android scales downwards so have to do all densities
*
inside each of these integers file i find the correct dpr to use based on density. so in values folder i use 2 as the default and then mdpi and hdpi will have 1 and 1.5 etc ...
here is the scale factor to use:
From this:
ldpi = 0.00625 * 120 -> 0.75 mdpi = 0.00625 * 160 -> 1.0 hdpi =0.00625 * 240 -> 1.5 xhdpi = 0.00625 * 320 -> 2.0 xxhdpi = 0.00625 * 480 -> 3.0 xxxhdpi = 0.00625 * 640 -> 4.0
from here So for example the default is:
and mdpi:
and hdpi:
then in code when i am buliding the imgix image i call the respectively value like this:
the entire call would look something like this in a custom view (in my case):