java.lang.Object | |
↳ | android.view.ViewTreeObserver |
A view tree observer is used to register listeners that can be notified of global
changes in the view tree. Such global events include, but are not limited to,
layout of the whole tree, beginning of the drawing pass, touch mode change....
A ViewTreeObserver should never be instantiated by applications as it is provided
by the views hierarchy. Refer to
getViewTreeObserver()
for more information.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
ViewTreeObserver.OnDrawListener | Interface definition for a callback to be invoked when the view tree is about to be drawn. | |||||||||
|
ViewTreeObserver.OnGlobalFocusChangeListener | Interface definition for a callback to be invoked when the focus state within the view tree changes. | |||||||||
|
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. | |||||||||
|
ViewTreeObserver.OnPreDrawListener | Interface definition for a callback to be invoked when the view tree is about to be drawn. | |||||||||
|
ViewTreeObserver.OnScrollChangedListener | Interface definition for a callback to be invoked when something in the view tree has been scrolled. | |||||||||
|
ViewTreeObserver.OnTouchModeChangeListener | Interface definition for a callback to be invoked when the touch mode changes. | |||||||||
|
ViewTreeObserver.OnWindowAttachListener | Interface definition for a callback to be invoked when the view hierarchy is attached to and detached from its window. | |||||||||
|
ViewTreeObserver.OnWindowFocusChangeListener | Interface definition for a callback to be invoked when the view hierarchy's window focus state changes. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Register a callback to be invoked when the view tree is about to be drawn. |
||||||||||
|
Register a callback to be invoked when the focus state within the view tree changes.
|
||||||||||
|
Register a callback to be invoked when the global layout state or the visibility of views
within the view tree changes
|
||||||||||
|
Register a callback to be invoked when the view tree is about to be drawn
|
||||||||||
|
Register a callback to be invoked when a view has been scrolled.
|
||||||||||
|
Register a callback to be invoked when the invoked when the touch mode changes.
|
||||||||||
|
Register a callback to be invoked when the view hierarchy is attached to a window.
|
||||||||||
|
Register a callback to be invoked when the window focus state within the view tree changes.
|
||||||||||
|
Notifies registered listeners that the drawing pass is about to start.
|
||||||||||
|
Notifies registered listeners that a global layout happened.
|
||||||||||
|
Notifies registered listeners that the drawing pass is about to start.
|
||||||||||
|
Indicates whether this ViewTreeObserver is alive.
|
||||||||||
|
This method was deprecated
in API level 16.
Use #removeOnGlobalLayoutListener instead
|
||||||||||
|
Remove a previously installed pre-draw callback. |
||||||||||
|
Remove a previously installed focus change callback.
|
||||||||||
|
Remove a previously installed global layout callback
|
||||||||||
|
Remove a previously installed pre-draw callback
|
||||||||||
|
Remove a previously installed scroll-changed callback
|
||||||||||
|
Remove a previously installed touch mode change callback
|
||||||||||
|
Remove a previously installed window attach callback.
|
||||||||||
|
Remove a previously installed window focus change callback.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Register a callback to be invoked when the view tree is about to be drawn.
Note:
this method
cannot
be invoked from
onDraw()
.
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when the focus state within the view tree changes.
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when the global layout state or the visibility of views within the view tree changes
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when the view tree is about to be drawn
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when a view has been scrolled.
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when the invoked when the touch mode changes.
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when the view hierarchy is attached to a window.
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Register a callback to be invoked when the window focus state within the view tree changes.
listener | The callback to add |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Notifies registered listeners that the drawing pass is about to start.
Notifies registered listeners that a global layout happened. This can be called manually if you are forcing a layout on a View or a hierarchy of Views that are not attached to a Window or in the GONE state.
Notifies registered listeners that the drawing pass is about to start. If a listener returns true, then the drawing pass is canceled and rescheduled. This can be called manually if you are forcing the drawing on a View or a hierarchy of Views that are not attached to a Window or in the GONE state.
Indicates whether this ViewTreeObserver is alive. When an observer is not alive, any call to a method (except this one) will throw an exception. If an application keeps a long-lived reference to this ViewTreeObserver, it should always check for the result of this method before calling any other method.
This method was deprecated
in API level 16.
Use #removeOnGlobalLayoutListener instead
Remove a previously installed global layout callback
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed pre-draw callback.
Note:
this method
cannot
be invoked from
onDraw()
.
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed focus change callback.
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed global layout callback
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed pre-draw callback
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed scroll-changed callback
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed touch mode change callback
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed window attach callback.
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|
Remove a previously installed window focus change callback.
victim | The callback to remove |
---|
IllegalStateException |
If
isAlive()
returns false
|
---|