java.lang.Object | |
↳ | android.view.Choreographer |
Coordinates the timing of animations, input and drawing.
The choreographer receives timing pulses (such as vertical synchronization) from the display subsystem then schedules work to occur as part of rendering the next display frame.
Applications typically interact with the choreographer indirectly using higher level abstractions in the animation framework or the view hierarchy. Here are some examples of things you can do using the higher-level APIs.
start()
.
Runnable
to be invoked once at the beginning of the next display
frame, use
postOnAnimation(Runnable)
.
Runnable
to be invoked once at the beginning of the next display
frame after a delay, use
postOnAnimationDelayed(Runnable, long)
.
invalidate()
to occur once at the beginning of the
next display frame, use
postInvalidateOnAnimation()
or
postInvalidateOnAnimation(int, int, int, int)
.
View
scroll smoothly and are drawn in
sync with display frame rendering, do nothing. This already happens automatically.
onDraw(Canvas)
will be called at the appropriate time.
However, there are a few cases where you might want to use the functions of the choreographer directly in your application. Here are some examples.
postFrameCallback(Choreographer.FrameCallback)
.
Each
Looper
thread has its own choreographer. Other threads can
post callbacks to run on the choreographer but they will run on the
Looper
to which the choreographer belongs.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Choreographer.FrameCallback | Implement this interface to receive a callback when a new display frame is being rendered. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Gets the choreographer for the calling thread.
|
||||||||||
|
Posts a frame callback to run on the next frame.
|
||||||||||
|
Posts a frame callback to run on the next frame after the specified delay.
|
||||||||||
|
Removes a previously posted frame callback.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Gets the choreographer for the calling thread. Must be called from
a thread that already has a
Looper
associated with it.
IllegalStateException | if the thread does not have a looper. |
---|
Posts a frame callback to run on the next frame.
The callback runs once then is automatically removed.
callback | The frame callback to run during the next frame. |
---|
Posts a frame callback to run on the next frame after the specified delay.
The callback runs once then is automatically removed.
callback | The frame callback to run during the next frame. |
---|---|
delayMillis | The delay time in milliseconds. |
Removes a previously posted frame callback.
callback | The frame callback to remove. |
---|