public final class ViewTreeObserver extends Object
View.getViewTreeObserver()
for more information.Modifier and Type | Class and Description |
---|---|
static class |
ViewTreeObserver.InternalInsetsInfo
Parameters used with OnComputeInternalInsetsListener.
|
static interface |
ViewTreeObserver.OnComputeInternalInsetsListener
Interface definition for a callback to be invoked when layout has
completed and the client can compute its interior insets.
|
static interface |
ViewTreeObserver.OnDrawListener
Interface definition for a callback to be invoked when the view tree is about to be drawn.
|
static interface |
ViewTreeObserver.OnGlobalFocusChangeListener
Interface definition for a callback to be invoked when the focus state within
the view tree changes.
|
static interface |
ViewTreeObserver.OnGlobalLayoutListener
Interface definition for a callback to be invoked when the global layout state
or the visibility of views within the view tree changes.
|
static interface |
ViewTreeObserver.OnPreDrawListener
Interface definition for a callback to be invoked when the view tree is about to be drawn.
|
static interface |
ViewTreeObserver.OnScrollChangedListener
Interface definition for a callback to be invoked when
something in the view tree has been scrolled.
|
static interface |
ViewTreeObserver.OnTouchModeChangeListener
Interface definition for a callback to be invoked when the touch mode changes.
|
Modifier and Type | Method and Description |
---|---|
void |
addOnComputeInternalInsetsListener(ViewTreeObserver.OnComputeInternalInsetsListener listener)
Register a callback to be invoked when the invoked when it is time to
compute the window's internal insets.
|
void |
addOnDrawListener(ViewTreeObserver.OnDrawListener listener)
Register a callback to be invoked when the view tree is about to be drawn.
|
void |
addOnGlobalFocusChangeListener(ViewTreeObserver.OnGlobalFocusChangeListener listener)
Register a callback to be invoked when the focus state within the view tree changes.
|
void |
addOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener)
Register a callback to be invoked when the global layout state or the visibility of views
within the view tree changes
|
void |
addOnPreDrawListener(ViewTreeObserver.OnPreDrawListener listener)
Register a callback to be invoked when the view tree is about to be drawn
|
void |
addOnScrollChangedListener(ViewTreeObserver.OnScrollChangedListener listener)
Register a callback to be invoked when a view has been scrolled.
|
void |
addOnTouchModeChangeListener(ViewTreeObserver.OnTouchModeChangeListener listener)
Register a callback to be invoked when the invoked when the touch mode changes.
|
void |
dispatchOnDraw()
Notifies registered listeners that the drawing pass is about to start.
|
void |
dispatchOnGlobalLayout()
Notifies registered listeners that a global layout happened.
|
boolean |
dispatchOnPreDraw()
Notifies registered listeners that the drawing pass is about to start.
|
boolean |
isAlive()
Indicates whether this ViewTreeObserver is alive.
|
void |
removeGlobalOnLayoutListener(ViewTreeObserver.OnGlobalLayoutListener victim)
Deprecated.
Use #removeOnGlobalLayoutListener instead
|
void |
removeOnComputeInternalInsetsListener(ViewTreeObserver.OnComputeInternalInsetsListener victim)
Remove a previously installed internal insets computation callback
|
void |
removeOnDrawListener(ViewTreeObserver.OnDrawListener victim)
Remove a previously installed pre-draw callback.
|
void |
removeOnGlobalFocusChangeListener(ViewTreeObserver.OnGlobalFocusChangeListener victim)
Remove a previously installed focus change callback.
|
void |
removeOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener victim)
Remove a previously installed global layout callback
|
void |
removeOnPreDrawListener(ViewTreeObserver.OnPreDrawListener victim)
Remove a previously installed pre-draw callback
|
void |
removeOnScrollChangedListener(ViewTreeObserver.OnScrollChangedListener victim)
Remove a previously installed scroll-changed callback
|
void |
removeOnTouchModeChangeListener(ViewTreeObserver.OnTouchModeChangeListener victim)
Remove a previously installed touch mode change callback
|
public void addOnGlobalFocusChangeListener(ViewTreeObserver.OnGlobalFocusChangeListener listener)
listener
- The callback to addIllegalStateException
- If isAlive()
returns falsepublic void removeOnGlobalFocusChangeListener(ViewTreeObserver.OnGlobalFocusChangeListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnGlobalFocusChangeListener(OnGlobalFocusChangeListener)
public void addOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener)
listener
- The callback to addIllegalStateException
- If isAlive()
returns false@Deprecated public void removeGlobalOnLayoutListener(ViewTreeObserver.OnGlobalLayoutListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnGlobalLayoutListener(OnGlobalLayoutListener)
public void removeOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnGlobalLayoutListener(OnGlobalLayoutListener)
public void addOnPreDrawListener(ViewTreeObserver.OnPreDrawListener listener)
listener
- The callback to addIllegalStateException
- If isAlive()
returns falsepublic void removeOnPreDrawListener(ViewTreeObserver.OnPreDrawListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnPreDrawListener(OnPreDrawListener)
public void addOnDrawListener(ViewTreeObserver.OnDrawListener listener)
Register a callback to be invoked when the view tree is about to be drawn.
Note: this method cannot be invoked from
ViewTreeObserver.OnDrawListener.onDraw()
.
listener
- The callback to addIllegalStateException
- If isAlive()
returns falsepublic void removeOnDrawListener(ViewTreeObserver.OnDrawListener victim)
Remove a previously installed pre-draw callback.
Note: this method cannot be invoked from
ViewTreeObserver.OnDrawListener.onDraw()
.
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnDrawListener(OnDrawListener)
public void addOnScrollChangedListener(ViewTreeObserver.OnScrollChangedListener listener)
listener
- The callback to addIllegalStateException
- If isAlive()
returns falsepublic void removeOnScrollChangedListener(ViewTreeObserver.OnScrollChangedListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnScrollChangedListener(OnScrollChangedListener)
public void addOnTouchModeChangeListener(ViewTreeObserver.OnTouchModeChangeListener listener)
listener
- The callback to addIllegalStateException
- If isAlive()
returns falsepublic void removeOnTouchModeChangeListener(ViewTreeObserver.OnTouchModeChangeListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseaddOnTouchModeChangeListener(OnTouchModeChangeListener)
public void addOnComputeInternalInsetsListener(ViewTreeObserver.OnComputeInternalInsetsListener listener)
listener
- The callback to addIllegalStateException
- If isAlive()
returns false
We are not yet ready to commit to this API and support it, sopublic void removeOnComputeInternalInsetsListener(ViewTreeObserver.OnComputeInternalInsetsListener victim)
victim
- The callback to removeIllegalStateException
- If isAlive()
returns falseWe are not yet ready to commit to this API and support it, so
public boolean isAlive()
public final void dispatchOnGlobalLayout()
public final boolean dispatchOnPreDraw()
public final void dispatchOnDraw()