Class ShadowDisplay
ShadowDisplay.- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic DisplayReturns the default display.protected voidgetMetrics(DisplayMetrics outMetrics) Deprecated.This behavior is deprecated and will be removed in Robolectric 4.13.protected voidgetRealMetrics(DisplayMetrics outMetrics) Deprecated.This behavior is deprecated and will be removed in Robolectric 4.13.protected floatDeprecated.This behavior is deprecated and will be removed in Robolectric 3.7.voidsetDensity(float density) Changes the density for this display.voidsetDensityDpi(int densityDpi) Changes the density for this display.voidsetDisplayCutout(Object displayCutout) Changes the display cutout for this display.voidsetDisplayHdrCapabilities(int displayId, float maxLuminance, float maxAverageLuminance, float minLuminance, int... supportedHdrTypes) Set HDR capabilities to the display sourced with displayId.voidsetFlags(int flags) Changes the flags for this display.voidsetHdrSdrRatio(float hdrSdrRatio) Sets current hdr/sdr ratio expressed as the ratio of targetHdrPeakBrightnessInNits / targetSdrWhitePointInNits.voidsetHeight(int height) Changes the height available to the application for this display.voidChanges the name for this display.voidsetRealHeight(int height) Changes the simulated physical height for this display.voidsetRealWidth(int width) Changes the simulated physical width for this display.voidsetRefreshRate(float refreshRate) Changes the refresh rate for this display.voidsetRotation(int rotation) Changes the rotation for this display.voidsetScaledDensity(float scaledDensity) Deprecated.This method is deprecated and will be removed in Robolectric 4.13.voidsetState(int state) Changes the simulated state for this display, such as whether it is on or offvoidsetWidth(int width) Changes the width available to the application for this display.voidsetXdpi(float xdpi) Changes the horizontal DPI for this display.voidsetYdpi(float ydpi) Changes the vertical DPI for this display.
- 
Constructor Details- 
ShadowDisplaypublic ShadowDisplay()
 
- 
- 
Method Details- 
getDefaultDisplayReturns the default display.- Returns:
- the default display
 
- 
getMetricsDeprecated.This behavior is deprecated and will be removed in Robolectric 4.13.IfsetScaledDensity(float)has been called,DisplayMetrics.scaledDensitywill be modified to reflect the value specified. Note that this is not a realistic state.
- 
getRealMetricsDeprecated.This behavior is deprecated and will be removed in Robolectric 4.13.IfsetScaledDensity(float)has been called,DisplayMetrics.scaledDensitywill be modified to reflect the value specified. Note that this is not a realistic state.
- 
setScaledDensityDeprecated.This method is deprecated and will be removed in Robolectric 4.13.Changes the scaled density for this display.
- 
getRefreshRateDeprecated.This behavior is deprecated and will be removed in Robolectric 3.7.IfsetRefreshRate(float)has been called, this method will return the specified value.
- 
setDensitypublic void setDensity(float density) Changes the density for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setDensityDpipublic void setDensityDpi(int densityDpi) Changes the density for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setXdpipublic void setXdpi(float xdpi) Changes the horizontal DPI for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setYdpipublic void setYdpi(float ydpi) Changes the vertical DPI for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setNameChanges the name for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setFlagspublic void setFlags(int flags) Changes the flags for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setWidthpublic void setWidth(int width) Changes the width available to the application for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.- Parameters:
- width- the new width in pixels
 
- 
setHeightpublic void setHeight(int height) Changes the height available to the application for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.- Parameters:
- height- new height in pixels
 
- 
setRealWidthpublic void setRealWidth(int width) Changes the simulated physical width for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.- Parameters:
- width- the new width in pixels
 
- 
setRealHeightpublic void setRealHeight(int height) Changes the simulated physical height for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.- Parameters:
- height- the new height in pixels
 
- 
setRefreshRatepublic void setRefreshRate(float refreshRate) Changes the refresh rate for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.
- 
setRotationpublic void setRotation(int rotation) Changes the rotation for this display.Any registered DisplayManager.DisplayListeners will be notified of the change.- Parameters:
- rotation- one of- Surface.ROTATION_0,- Surface.ROTATION_90,- Surface.ROTATION_180,- Surface.ROTATION_270
 
- 
setStatepublic void setState(int state) Changes the simulated state for this display, such as whether it is on or offAny registered DisplayManager.DisplayListeners will be notified of the change.- Parameters:
- state- the new state: one of- Display.STATE_OFF,- Display.STATE_ON,- Display.STATE_DOZE,- Display.STATE_DOZE_SUSPEND, or- Display.STATE_UNKNOWN.
 
- 
setDisplayHdrCapabilitiespublic void setDisplayHdrCapabilities(int displayId, float maxLuminance, float maxAverageLuminance, float minLuminance, int... supportedHdrTypes) Set HDR capabilities to the display sourced with displayId. seeDisplay.HdrCapabilitiesfor supportedHdrTypes.- Throws:
- UnsupportedOperationException- if the method is called below Android version N.
 
- 
setHdrSdrRatiopublic void setHdrSdrRatio(float hdrSdrRatio) Sets current hdr/sdr ratio expressed as the ratio of targetHdrPeakBrightnessInNits / targetSdrWhitePointInNits. This will have the intended side effect of makingDisplay.isHdrSdrRatioAvailable()equal to true if set to any value other thanFloat.NaN.- Throws:
- UnsupportedOperationException- if the method is called below Android version U.
 
- 
setDisplayCutoutChanges the display cutout for this display.- Throws:
- UnsupportedOperationException- if the method is called below Android version Q.
 
 
-