Class DisplayMetrics

java.lang.Object
icyllis.modernui.util.DisplayMetrics

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

    • DENSITY_LOW

      public static final int DENSITY_LOW
      Standard quantized DPI for low-density screens.
      See Also:
    • DENSITY_84

      public static final int DENSITY_84
      Intermediate density for screens that sit between DENSITY_LOW (72dpi) and DENSITY_MEDIUM (96dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_MEDIUM assets for them.
      See Also:
    • DENSITY_MEDIUM

      public static final int DENSITY_MEDIUM
      Standard quantized DPI for medium-density screens.
      See Also:
    • DENSITY_108

      public static final int DENSITY_108
      Intermediate density for screens that sit between DENSITY_MEDIUM (96dpi) and DENSITY_HIGH (144dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_HIGH assets for them.
      See Also:
    • DENSITY_120

      public static final int DENSITY_120
      Intermediate density for screens that sit between DENSITY_MEDIUM (96dpi) and DENSITY_HIGH (144dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_HIGH assets for them.
      See Also:
    • DENSITY_132

      public static final int DENSITY_132
      Intermediate density for screens that sit between DENSITY_MEDIUM (96dpi) and DENSITY_HIGH (144dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_HIGH assets for them.
      See Also:
    • DENSITY_HIGH

      public static final int DENSITY_HIGH
      Standard quantized DPI for high-density screens.
      See Also:
    • DENSITY_156

      public static final int DENSITY_156
      Intermediate density for screens that sit between DENSITY_HIGH (144dpi) and DENSITY_XHIGH (192dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XHIGH assets for them.
      See Also:
    • DENSITY_168

      public static final int DENSITY_168
      Intermediate density for screens that sit between DENSITY_HIGH (144dpi) and DENSITY_XHIGH (192dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XHIGH assets for them.
      See Also:
    • DENSITY_180

      public static final int DENSITY_180
      Intermediate density for screens that sit between DENSITY_HIGH (144dpi) and DENSITY_XHIGH (192dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XHIGH assets for them.
      See Also:
    • DENSITY_XHIGH

      public static final int DENSITY_XHIGH
      Standard quantized DPI for extra-high-density screens.
      See Also:
    • DENSITY_204

      public static final int DENSITY_204
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_216

      public static final int DENSITY_216
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_228

      public static final int DENSITY_228
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_240

      public static final int DENSITY_240
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_252

      public static final int DENSITY_252
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_264

      public static final int DENSITY_264
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_276

      public static final int DENSITY_276
      Intermediate density for screens that sit somewhere between DENSITY_XHIGH (192 dpi) and DENSITY_XXHIGH (288 dpi). This is not a density that applications should target, instead relying on the system to scale their DENSITY_XXHIGH assets for them.
      See Also:
    • DENSITY_XXHIGH

      public static final int DENSITY_XXHIGH
      Standard quantized DPI for extra-extra-high-density screens.
      See Also:
    • DENSITY_DEFAULT

      public static final int DENSITY_DEFAULT
      The reference density used throughout the system.
      See Also:
    • DENSITY_DEFAULT_SCALE

      public static final float DENSITY_DEFAULT_SCALE
      Scaling factor to convert a density in DPI units to the density scale.
      See Also:
    • widthPixels

      public int widthPixels
      The absolute width of the available display size in pixels.
    • heightPixels

      public int heightPixels
      The absolute height of the available display size in pixels.
    • density

      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 72 dpi screen, providing the baseline of the system's display. Thus on a 72 dpi screen this density value will be 1; on a 96 dpi screen it would be 1.33; etc.

      This value does not exactly follow the real screen size (as given by xdpi and ydpi), but rather is used to scale the size of the overall UI in steps based on gross changes in the display dpi.

      See Also:
    • densityDpi

      public int densityDpi
      The screen density expressed as dots-per-inch.
      May be either DENSITY_LOW, DENSITY_MEDIUM, or DENSITY_HIGH.
    • scaledDensity

      public float scaledDensity
      A scaling factor for fonts displayed on the display.
      This is the same as density, except that it may be adjusted in smaller increments at runtime based on a user preference for the font size.
    • xdpi

      public float xdpi
      The exact physical pixels per inch of the screen in the X dimension.
    • ydpi

      public float ydpi
      The exact physical pixels per inch of the screen in the Y dimension.
  • Constructor Details

    • DisplayMetrics

      public DisplayMetrics()
  • Method Details

    • setTo

      public void setTo(DisplayMetrics o)
    • setToDefaults

      public void setToDefaults()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(DisplayMetrics other)
      Returns true if these display metrics equal the other display metrics.
      Parameters:
      other - The display metrics with which to compare.
      Returns:
      True if the display metrics are equal.
    • equalsPhysical

      public boolean equalsPhysical(DisplayMetrics other)
      Returns true if the physical aspects of the two display metrics are equal. This ignores the scaled density, which is a logical attribute based on the current desired font size.
      Parameters:
      other - The display metrics with which to compare.
      Returns:
      True if the display metrics are equal.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object