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
Modifier and TypeFieldDescriptionfloat
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.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 betweenDENSITY_LOW
(72dpi) andDENSITY_MEDIUM
(96dpi).static final int
The reference density used throughout the system.static final float
Scaling factor to convert a density in DPI units to the density scale.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.int
The screen density expressed as dots-per-inch.
May be eitherDENSITY_LOW
,DENSITY_MEDIUM
, orDENSITY_HIGH
.int
The absolute height of the available display size in pixels.float
A scaling factor for fonts displayed on the display.
This is the same asdensity
, except that it may be adjusted in smaller increments at runtime based on a user preference for the font size.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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
equals
(DisplayMetrics other) Returns true if these display metrics equal the other display metrics.boolean
boolean
equalsPhysical
(DisplayMetrics other) Returns true if the physical aspects of the two display metrics are equal.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_228
public static final int DENSITY_228Intermediate 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_276
public static final int DENSITY_276Intermediate 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_DEFAULT
public static final int DENSITY_DEFAULTThe reference density used throughout the system.- See Also:
-
DENSITY_DEFAULT_SCALE
public static final float DENSITY_DEFAULT_SCALEScaling factor to convert a density in DPI units to the density scale.- 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 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
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 eitherDENSITY_LOW
,DENSITY_MEDIUM
, orDENSITY_HIGH
. -
scaledDensity
public float scaledDensityA scaling factor for fonts displayed on the display.
This is the same asdensity
, except that it may be adjusted in smaller increments at runtime based on a user preference for the font size. -
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.
-
equalsPhysical
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() -
toString
-