Package icyllis.modernui.util
Class DisplayMetrics
java.lang.Object
icyllis.modernui.util.DisplayMetrics
A structure describing general information about a display, such as its
size, density, and font scaling.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfloat
The logical density of the display.
This is a scaling factor for the Density-independent Pixel unit, where one DP is one pixel on an approximately 96 dpi screen, providing the baseline of the system's display.static final int
Intermediate density for screens that sit betweenDENSITY_MEDIUM
(96dpi) andDENSITY_HIGH
(144dpi).static final int
Intermediate density for screens that sit betweenDENSITY_MEDIUM
(96dpi) andDENSITY_HIGH
(144dpi).static final int
Intermediate density for screens that sit betweenDENSITY_MEDIUM
(96dpi) andDENSITY_HIGH
(144dpi).static final int
Intermediate density for screens that sit betweenDENSITY_HIGH
(144dpi) andDENSITY_XHIGH
(192dpi).static final int
Intermediate density for screens that sit betweenDENSITY_HIGH
(144dpi) andDENSITY_XHIGH
(192dpi).static final int
Intermediate density for screens that sit betweenDENSITY_HIGH
(144dpi) andDENSITY_XHIGH
(192dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XXHIGH
(288 dpi) andDENSITY_XXXHIGH
(384 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XXHIGH
(288 dpi) andDENSITY_XXXHIGH
(384 dpi).static final int
Intermediate density for screens that sit somewhere betweenDENSITY_XXHIGH
(288 dpi) andDENSITY_XXXHIGH
(384 dpi).static final int
Intermediate density for screens that sit betweenDENSITY_LOW
(72dpi) andDENSITY_MEDIUM
(96dpi).static final int
The reference density used throughout the system.static final int
Standard quantized DPI for high-density screens.static final int
Standard quantized DPI for low-density screens.static final int
Standard quantized DPI for medium-density screens.static final int
Standard quantized DPI for extra-high-density screens.static final int
Standard quantized DPI for extra-extra-high-density screens.static final int
Standard quantized DPI for extra-extra-extra-high-density screens.int
The screen density expressed as dots-per-inch.int
The absolute height of the available display size in pixels.int
The absolute width of the available display size in pixels.float
The exact physical pixels per inch of the screen in the X dimension.float
The exact physical pixels per inch of the screen in the Y dimension. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
equals
(DisplayMetrics other) Returns true if these display metrics equal the other display metrics.boolean
int
hashCode()
void
void
toString()
-
Field Details
-
DENSITY_LOW
public static final int DENSITY_LOWStandard quantized DPI for low-density screens.- See Also:
-
DENSITY_84
public static final int DENSITY_84Intermediate density for screens that sit betweenDENSITY_LOW
(72dpi) andDENSITY_MEDIUM
(96dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_MEDIUM
assets for them.- See Also:
-
DENSITY_MEDIUM
public static final int DENSITY_MEDIUMStandard quantized DPI for medium-density screens.- See Also:
-
DENSITY_108
public static final int DENSITY_108Intermediate density for screens that sit betweenDENSITY_MEDIUM
(96dpi) andDENSITY_HIGH
(144dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_HIGH
assets for them.- See Also:
-
DENSITY_120
public static final int DENSITY_120Intermediate density for screens that sit betweenDENSITY_MEDIUM
(96dpi) andDENSITY_HIGH
(144dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_HIGH
assets for them.- See Also:
-
DENSITY_132
public static final int DENSITY_132Intermediate density for screens that sit betweenDENSITY_MEDIUM
(96dpi) andDENSITY_HIGH
(144dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_HIGH
assets for them.- See Also:
-
DENSITY_HIGH
public static final int DENSITY_HIGHStandard quantized DPI for high-density screens.- See Also:
-
DENSITY_156
public static final int DENSITY_156Intermediate density for screens that sit betweenDENSITY_HIGH
(144dpi) andDENSITY_XHIGH
(192dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XHIGH
assets for them.- See Also:
-
DENSITY_168
public static final int DENSITY_168Intermediate density for screens that sit betweenDENSITY_HIGH
(144dpi) andDENSITY_XHIGH
(192dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XHIGH
assets for them.- See Also:
-
DENSITY_180
public static final int DENSITY_180Intermediate density for screens that sit betweenDENSITY_HIGH
(144dpi) andDENSITY_XHIGH
(192dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XHIGH
assets for them.- See Also:
-
DENSITY_XHIGH
public static final int DENSITY_XHIGHStandard quantized DPI for extra-high-density screens.- See Also:
-
DENSITY_204
public static final int DENSITY_204Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_216
public static final int DENSITY_216Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_234
public static final int DENSITY_234Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_240
public static final int DENSITY_240Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_252
public static final int DENSITY_252Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_264
public static final int DENSITY_264Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_270
public static final int DENSITY_270Intermediate density for screens that sit somewhere betweenDENSITY_XHIGH
(192 dpi) andDENSITY_XXHIGH
(288 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXHIGH
assets for them.- See Also:
-
DENSITY_XXHIGH
public static final int DENSITY_XXHIGHStandard quantized DPI for extra-extra-high-density screens.- See Also:
-
DENSITY_312
public static final int DENSITY_312Intermediate density for screens that sit somewhere betweenDENSITY_XXHIGH
(288 dpi) andDENSITY_XXXHIGH
(384 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXXHIGH
assets for them.- See Also:
-
DENSITY_336
public static final int DENSITY_336Intermediate density for screens that sit somewhere betweenDENSITY_XXHIGH
(288 dpi) andDENSITY_XXXHIGH
(384 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXXHIGH
assets for them.- See Also:
-
DENSITY_360
public static final int DENSITY_360Intermediate density for screens that sit somewhere betweenDENSITY_XXHIGH
(288 dpi) andDENSITY_XXXHIGH
(384 dpi). This is not a density that applications should target, instead relying on the system to scale theirDENSITY_XXXHIGH
assets for them.- See Also:
-
DENSITY_XXXHIGH
public static final int DENSITY_XXXHIGHStandard quantized DPI for extra-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.- See Also:
-
DENSITY_DEFAULT
public static final int DENSITY_DEFAULTThe reference density used throughout the system.- See Also:
-
widthPixels
public int widthPixelsThe absolute width of the available display size in pixels. -
heightPixels
public int heightPixelsThe absolute height of the available display size in pixels. -
density
public float densityThe logical density of the display.
This is a scaling factor for the Density-independent Pixel unit, where one DP is one pixel on an approximately 96 dpi screen, providing the baseline of the system's display. Thus on a 96 dpi screen this density value will be 1; on a 72 dpi screen it would be .75; etc.This value does not exactly follow the real screen size (as given by
xdpi
andydpi
), 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 densityDpiThe screen density expressed as dots-per-inch. May be any one of theDENSITY_
constants defined above. -
xdpi
public float xdpiThe exact physical pixels per inch of the screen in the X dimension. -
ydpi
public float ydpiThe exact physical pixels per inch of the screen in the Y dimension.
-
-
Constructor Details
-
DisplayMetrics
public DisplayMetrics()
-
-
Method Details
-
setTo
-
setToDefaults
public void setToDefaults() -
equals
-
equals
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.
-
hashCode
public int hashCode() -
toString
-