Friday, January 17, 2014

Programming things to remember 2013 Nov

Convert dp to px


Without explaining what is a dp, if you want to know how many pixel is a couple of dps, these are the equations you should use:

dp = px * 160 / referenceDpi
px = dp * (referenceDpi / 160)

referenceDpi is the dpi value you are developing for. Or (as in our case was, where the design was "ported" from iPhone) the dpi of the iPhone (= 330). So roughly to get dp from iPhone design, divide the px value by two.

No comments: