I have developed an Android app with an Emulator (5.4") from Eclipse.
I have tested this app and everything works well, but I want to adapt my app for different smartphone's sizes and for different tablet's sizes. I have created some folders 'values' with differents suffixes like '-ldpi' '-mdpi' '-hdpi' '-xhdpi' which contain a 'dimens.xml' file with the amounts in 'dp' for each element from layouts.
Moreover, I have an pdf with the amounts in pixels which I must use for each element, but I don't know how use them. This design that I must use is in 1280x720 px but I don't know how adapt those amounts in pixels for each 'dimens.xml' file (ldpi, mdpi, hdpi, xhdpi) in my app.
For example, if the design has 720 px for width and a button has 50 px, how many 'dp' I must put in each 'dimens' file according to the density?
I have found some webs app that it converts me the amounts in dp from one density to other, but I don't know how to adapt the pixels to dp and what density I must use like reference ...
I hope you can help me!
Thanks xD
EDIT:
I managed to get a good result for my smartphone is XHDPI. Now for the emulator is MDPI I put in 'values-mdpi/dimens.xml' the dp (x2) respect to XHPDI following this rule:
Density:
ldpi | mdpi | tvdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
0.75 | 1 | 1.33 | 1.5 | 2 | 3 | 4
float dp = somePxValue / density;
but the visual result is not the same, is not correct. Why¿?
I've been testing, and to get the same aspect of the app in the emulator MDPI than in my smartphone XHDPI must follow the following relationship:
dp (MDPI) = dp (XHDPI) x 1.35
Can anyone explain to me why this is so?
0.75:1:1.5:2:3:4
rule for scale factors. 1 being mdpi – Phantômaxxresolution
withdensity
– Phantômaxx