public final class WindowInsets extends Object
WindowInsets are immutable and may be expanded to include more inset types in the future. To adjust insets, use one of the supplied clone methods to obtain a new WindowInsets instance with the adjusted properties.
Modifier and Type | Field and Description |
---|---|
static WindowInsets |
CONSUMED
Since new insets may be added in the future that existing apps couldn't
know about, this fully empty constant shouldn't be made available to apps
since it would allow them to inadvertently consume unknown insets by returning it.
|
Constructor and Description |
---|
WindowInsets(Rect systemWindowInsets) |
WindowInsets(Rect systemWindowInsets,
Rect windowDecorInsets,
Rect stableInsets,
boolean isRound,
boolean alwaysConsumeNavBar) |
WindowInsets(WindowInsets src)
Construct a new WindowInsets, copying all values from a source WindowInsets.
|
Modifier and Type | Method and Description |
---|---|
WindowInsets |
consumeStableInsets()
Returns a copy of this WindowInsets with the stable insets fully consumed.
|
WindowInsets |
consumeSystemWindowInsets()
Returns a copy of this WindowInsets with the system window insets fully consumed.
|
WindowInsets |
consumeSystemWindowInsets(boolean left,
boolean top,
boolean right,
boolean bottom)
Returns a copy of this WindowInsets with selected system window insets fully consumed.
|
WindowInsets |
consumeWindowDecorInsets() |
WindowInsets |
consumeWindowDecorInsets(boolean left,
boolean top,
boolean right,
boolean bottom) |
int |
getStableInsetBottom()
Returns the bottom stable inset in pixels.
|
int |
getStableInsetLeft()
Returns the left stable inset in pixels.
|
int |
getStableInsetRight()
Returns the right stable inset in pixels.
|
int |
getStableInsetTop()
Returns the top stable inset in pixels.
|
int |
getSystemWindowInsetBottom()
Returns the bottom system window inset in pixels.
|
int |
getSystemWindowInsetLeft()
Returns the left system window inset in pixels.
|
int |
getSystemWindowInsetRight()
Returns the right system window inset in pixels.
|
Rect |
getSystemWindowInsets()
Used to provide a safe copy of the system window insets to pass through
to the existing fitSystemWindows method and other similar internals.
|
int |
getSystemWindowInsetTop()
Returns the top system window inset in pixels.
|
int |
getWindowDecorInsetBottom()
Returns the bottom window decor inset in pixels.
|
int |
getWindowDecorInsetLeft()
Returns the left window decor inset in pixels.
|
int |
getWindowDecorInsetRight()
Returns the right window decor inset in pixels.
|
int |
getWindowDecorInsetTop()
Returns the top window decor inset in pixels.
|
boolean |
hasInsets()
Returns true if this WindowInsets has any nonzero insets.
|
boolean |
hasStableInsets()
Returns true if this WindowInsets has nonzero stable insets.
|
boolean |
hasSystemWindowInsets()
Returns true if this WindowInsets has nonzero system window insets.
|
boolean |
hasWindowDecorInsets()
Returns true if this WindowInsets has nonzero window decor insets.
|
boolean |
isConsumed()
Check if these insets have been fully consumed.
|
boolean |
isRound()
Returns true if the associated window has a round shape.
|
WindowInsets |
replaceSystemWindowInsets(int left,
int top,
int right,
int bottom)
Returns a copy of this WindowInsets with selected system window insets replaced
with new values.
|
WindowInsets |
replaceSystemWindowInsets(Rect systemWindowInsets)
Returns a copy of this WindowInsets with selected system window insets replaced
with new values.
|
WindowInsets |
replaceWindowDecorInsets(int left,
int top,
int right,
int bottom) |
boolean |
shouldAlwaysConsumeNavBar() |
String |
toString()
Returns a string representation of the object.
|
public static final WindowInsets CONSUMED
public WindowInsets(Rect systemWindowInsets, Rect windowDecorInsets, Rect stableInsets, boolean isRound, boolean alwaysConsumeNavBar)
public WindowInsets(WindowInsets src)
src
- Source to copy insets frompublic WindowInsets(Rect systemWindowInsets)
public Rect getSystemWindowInsets()
public int getSystemWindowInsetLeft()
The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.
public int getSystemWindowInsetTop()
The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.
public int getSystemWindowInsetRight()
The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.
public int getSystemWindowInsetBottom()
The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.
public int getWindowDecorInsetLeft()
The window decor inset represents the area of the window content area that is partially or fully obscured by decorations within the window provided by the framework. This can include action bars, title bars, toolbars, etc.
public int getWindowDecorInsetTop()
The window decor inset represents the area of the window content area that is partially or fully obscured by decorations within the window provided by the framework. This can include action bars, title bars, toolbars, etc.
public int getWindowDecorInsetRight()
The window decor inset represents the area of the window content area that is partially or fully obscured by decorations within the window provided by the framework. This can include action bars, title bars, toolbars, etc.
public int getWindowDecorInsetBottom()
The window decor inset represents the area of the window content area that is partially or fully obscured by decorations within the window provided by the framework. This can include action bars, title bars, toolbars, etc.
public boolean hasSystemWindowInsets()
The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.
public boolean hasWindowDecorInsets()
The window decor inset represents the area of the window content area that is partially or fully obscured by decorations within the window provided by the framework. This can include action bars, title bars, toolbars, etc.
public boolean hasInsets()
public boolean isConsumed()
Insets are considered "consumed" if the applicable consume*
methods
have been called such that all insets have been set to zero. This affects propagation of
insets through the view hierarchy; insets that have not been fully consumed will continue
to propagate down to child views.
The result of this method is equivalent to the return value of
View.fitSystemWindows(android.graphics.Rect)
.
public boolean isRound()
A round window's left, top, right and bottom edges reach all the way to the associated edges of the window but the corners may not be visible. Views responding to round insets should take care to not lay out critical elements within the corners where they may not be accessible.
public WindowInsets consumeSystemWindowInsets()
public WindowInsets consumeSystemWindowInsets(boolean left, boolean top, boolean right, boolean bottom)
left
- true to consume the left system window insettop
- true to consume the top system window insetright
- true to consume the right system window insetbottom
- true to consume the bottom system window insetpublic WindowInsets replaceSystemWindowInsets(int left, int top, int right, int bottom)
left
- New left inset in pixelstop
- New top inset in pixelsright
- New right inset in pixelsbottom
- New bottom inset in pixelspublic WindowInsets replaceSystemWindowInsets(Rect systemWindowInsets)
systemWindowInsets
- New system window insets. Each field is the inset in pixels
for that edgepublic WindowInsets consumeWindowDecorInsets()
public WindowInsets consumeWindowDecorInsets(boolean left, boolean top, boolean right, boolean bottom)
public WindowInsets replaceWindowDecorInsets(int left, int top, int right, int bottom)
public int getStableInsetTop()
The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.
public int getStableInsetLeft()
The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.
public int getStableInsetRight()
The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.
public int getStableInsetBottom()
The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.
public boolean hasStableInsets()
The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.
public WindowInsets consumeStableInsets()
public boolean shouldAlwaysConsumeNavBar()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())