FileDocCategorySizeDatePackage
DisplayMetrics.javaAPI DocAndroid 1.5 API3314Wed May 06 22:41:56 BST 2009android.util

DisplayMetrics

public class DisplayMetrics extends Object
A structure describing general information about a display, such as its size, density, and font scaling.

Fields Summary
public static final int
DEFAULT_DENSITY
The reference density used throughout the system.
private static final int
sLcdDensity
public int
widthPixels
The absolute width of the display in pixels.
public int
heightPixels
The absolute height of the display in pixels.
public float
density
The logical density of the display. This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen), providing the baseline of the system's display. Thus on a 160dpi screen this density value will be 1; on a 106 dpi screen it would be .75; etc.

This value does not exactly follow the real screen size (as given by {@link #xdpi} and {@link #ydpi}, but rather is used to scale the size of the overall UI in steps based on gross changes in the display dpi. For example, a 240x320 screen will have a density of 1 even if its width is 1.8", 1.3", etc. However, if the screen resolution is increased to 320x480 but the screen size remained 1.5"x2" then the density would be increased (probably to 1.5).

public float
scaledDensity
A scaling factor for fonts displayed on the display. This is the same as {@link #density}, except that it may be adjusted in smaller increments at runtime based on a user preference for the font size.
public float
xdpi
The exact physical pixels per inch of the screen in the X dimension.
public float
ydpi
The exact physical pixels per inch of the screen in the Y dimension.
Constructors Summary
public DisplayMetrics()


      
    
Methods Summary
public voidsetTo(android.util.DisplayMetrics o)

        widthPixels = o.widthPixels;
        heightPixels = o.heightPixels;
        density = o.density;
        scaledDensity = o.scaledDensity;
        xdpi = o.xdpi;
        ydpi = o.ydpi;
    
public voidsetToDefaults()

        widthPixels = 0;
        heightPixels = 0;
        density = sLcdDensity / (float) DEFAULT_DENSITY;
        scaledDensity = density;
        xdpi = sLcdDensity;
        ydpi = sLcdDensity;