Reputation: 3412
What're or where can I find the most popular device dpi specifications ? I have a layout where ImageView's are parameterized with dp values and in order to provide the best fit for any device there's a server that given specific pixel params can generate necessary images.
So, regarding px = dp * (dpi / 160)
I need to define most popular dpi variants to calculate pixel data for the server.
Thanks.
Upvotes: 2
Views: 5953
Reputation: 20041
// these are the only density Google API is supporting.
Device manufacturer can supply there own density for there device
suppose galaxy 3 is 306 dpi
but android will take it as 306/160=1.9
so it an DENSITY_XHIGH
it will get resource from xhdpi.
public static final int DENSITY_DEFAULT
Since: API Level 4
The reference density used throughout the system.
Constant Value: 160 (0x000000a0)
public static final int DENSITY_HIGH
Since: API Level 4
Standard quantized DPI for high-density screens.
Constant Value: 240 (0x000000f0)
public static final int DENSITY_LOW
Since: API Level 4
Standard quantized DPI for low-density screens.
Constant Value: 120 (0x00000078)
public static final int DENSITY_MEDIUM
Since: API Level 4
Standard quantized DPI for medium-density screens.
Constant Value: 160 (0x000000a0)
public static final int DENSITY_TV
Since: API Level 13
This is a secondary density, added for some common screen configurations. It is recommended that applications not generally target this as a first class density -- that is, don't supply specific graphics for this density, instead allow the platform to scale from other densities (typically DENSITY_HIGH) as appropriate. In most cases (such as using bitmaps in Drawable) the platform can perform this scaling at load time, so the only cost is some slight startup runtime overhead.
This density was original introduced to correspond with a 720p TV screen: the density for 1080p televisions is DENSITY_XHIGH, and the value here provides the same UI size for a TV running at 720p. It has also found use in 7" tablets, when these devices have 1280x720 displays.
Constant Value: 213 (0x000000d5)
public static final int DENSITY_XHIGH
Since: API Level 9
Standard quantized DPI for extra-high-density screens.
Constant Value: 320 (0x00000140)
public static final int DENSITY_XXHIGH
Since: API Level 16
Standard quantized DPI for extra-extra-high-density screens. Applications should not generally worry about this density; relying on XHIGH graphics being scaled up to it should be sufficient for almost all cases.
Constant Value: 480 (0x000001e0)
Upvotes: 0
Reputation: 11050
You can actually query the server with the exact size you need.
float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, intContainingYourDPs, getResources().getDisplayMetrics());
Upvotes: 1