| <html devsite="true"> |
| <head> |
| <title>KeyframesSpec</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <div id="metadata-info-block"></div> |
| <h1>KeyframesSpec</h1> |
| <p> |
| <pre>public final class <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html">KeyframesSpec</a><T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> implements <a href="/reference/androidx/compose/animation/core/DurationBasedAnimationSpec.html">DurationBasedAnimationSpec</a></pre> |
| </p> |
| <hr> |
| <p><code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.html">KeyframesSpec</a></code> creates a <code><a href="/reference/androidx/compose/animation/core/VectorizedKeyframesSpec.html">VectorizedKeyframesSpec</a></code> animation.</p> |
| <p><code><a href="/reference/androidx/compose/animation/core/VectorizedKeyframesSpec.html">VectorizedKeyframesSpec</a></code> animates based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be defined using <code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html#(kotlin.Any).at(kotlin.Int)">KeyframesSpecConfig.at</a></code>. <code><a href="/reference/androidx/compose/animation/core/VectorizedKeyframesSpec.html">VectorizedKeyframesSpec</a></code> allows very specific animation definitions with a precision to millisecond.</p> |
| <pre class="prettyprint"> |
| import androidx.compose.animation.core.KeyframesSpec |
| |
| KeyframesSpec( |
| KeyframesSpec.KeyframesSpecConfig<Float>().apply { |
| 0f at 0 // ms // Optional |
| 0.4f at 75 // ms |
| 0.4f at 225 // ms |
| 0f at 375 // ms // Optional |
| durationMillis = 375 |
| } |
| )</pre> |
| <p>You can also provide a custom <code><a href="/reference/androidx/compose/animation/core/Easing.html">Easing</a></code> for the interval with use of <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/index.html">with</a></code> function applied for the interval starting keyframe.</p> |
| <pre class="prettyprint"> |
| import androidx.compose.animation.core.keyframes |
| |
| // Use FastOutSlowInEasing for the interval from 0 to 50 ms, and LinearOutSlowInEasing for the |
| // time between 50 and 100ms |
| keyframes<Float> { |
| durationMillis = 100 |
| 0f at 0 with FastOutSlowInEasing |
| 1.5f at 50 with LinearOutSlowInEasing |
| 1f at 100 |
| }</pre> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Nested types</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td> |
| <div><code>public final class <a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframeEntity.html">KeyframesSpec.KeyframeEntity</a><T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></code></div> |
| <p>Holder class for building a keyframes animation.</p> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <div><code>public final class <a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html">KeyframesSpec.KeyframesSpecConfig</a><T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></code></div> |
| <p><code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html">KeyframesSpecConfig</a></code> stores a mutable configuration of the key frames, including <code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html#durationMillis()">durationMillis</a></code>, <code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html#delayMillis()">delayMillis</a></code>, and all the key frames.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public fields</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td width="40%"><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html">KeyframesSpec.KeyframesSpecConfig</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T></code></td> |
| <td> |
| <div><code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#config()">config</a></code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public constructors</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td> |
| <div><code><T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#KeyframesSpec(androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig)">KeyframesSpec</a>(<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html">KeyframesSpec.KeyframesSpecConfig</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T> config<br>)</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public methods</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td width="40%"><code>boolean</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#equals(kotlin.Any)">equals</a>(<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a> other)</code></div> |
| </td> |
| </tr> |
| <tr> |
| <td width="40%"><code>int</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#hashCode()">hashCode</a>()</code></div> |
| </td> |
| </tr> |
| <tr> |
| <td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/VectorizedKeyframesSpec.html">VectorizedKeyframesSpec</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V></code></td> |
| <td> |
| <div><code><V extends <a href="/reference/androidx/compose/animation/core/AnimationVector.html">AnimationVector</a>> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#vectorize(androidx.compose.animation.core.TwoWayConverter)">vectorize</a>(<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/TwoWayConverter.html">TwoWayConverter</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V> converter<br>)</code></div> |
| <p>Creates a <code><a href="/reference/androidx/compose/animation/core/VectorizedAnimationSpec.html">VectorizedAnimationSpec</a></code> with the given <code><a href="/reference/androidx/compose/animation/core/TwoWayConverter.html">TwoWayConverter</a></code>.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="list"> |
| <h2>Public fields</h2> |
| <div class="api-item"><a name="getConfig()"></a><a name="setConfig()"></a><a name="getConfig--"></a><a name="setConfig--"></a> |
| <h3 class="api-name" id="config()">config</h3> |
| <pre class="api-signature no-pretty-print">public final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html">KeyframesSpec.KeyframesSpecConfig</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#config()">config</a></pre> |
| </div> |
| </div> |
| <div class="list"> |
| <h2>Public constructors</h2> |
| <div class="api-item"><a name="KeyframesSpec-androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig-"></a><a name="keyframesspec"></a> |
| <h3 class="api-name" id="KeyframesSpec(androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig)">KeyframesSpec</h3> |
| <pre class="api-signature no-pretty-print">public <T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#KeyframesSpec(androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig)">KeyframesSpec</a>(<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig.html">KeyframesSpec.KeyframesSpecConfig</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T> config<br>)</pre> |
| </div> |
| </div> |
| <div class="list"> |
| <h2>Public methods</h2> |
| <div class="api-item"><a name="equals-kotlin.Any-"></a><a name="equals"></a> |
| <h3 class="api-name" id="equals(kotlin.Any)">equals</h3> |
| <pre class="api-signature no-pretty-print">public boolean <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#equals(kotlin.Any)">equals</a>(<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a> other)</pre> |
| </div> |
| <div class="api-item"><a name="hashCode--"></a><a name="hashcode"></a> |
| <h3 class="api-name" id="hashCode()">hashCode</h3> |
| <pre class="api-signature no-pretty-print">public int <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#hashCode()">hashCode</a>()</pre> |
| </div> |
| <div class="api-item"><a name="vectorize-androidx.compose.animation.core.TwoWayConverter-"></a><a name="vectorize"></a> |
| <h3 class="api-name" id="vectorize(androidx.compose.animation.core.TwoWayConverter)">vectorize</h3> |
| <pre class="api-signature no-pretty-print">public @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/VectorizedKeyframesSpec.html">VectorizedKeyframesSpec</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V> <V extends <a href="/reference/androidx/compose/animation/core/AnimationVector.html">AnimationVector</a>> <a href="/reference/androidx/compose/animation/core/KeyframesSpec.html#vectorize(androidx.compose.animation.core.TwoWayConverter)">vectorize</a>(<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/TwoWayConverter.html">TwoWayConverter</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V> converter<br>)</pre> |
| <p>Creates a <code><a href="/reference/androidx/compose/animation/core/VectorizedAnimationSpec.html">VectorizedAnimationSpec</a></code> with the given <code><a href="/reference/androidx/compose/animation/core/TwoWayConverter.html">TwoWayConverter</a></code>.</p> |
| <p>The underlying animation system operates on <code><a href="/reference/androidx/compose/animation/core/AnimationVector.html">AnimationVector</a></code>s. <code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.html">T</a></code> will be converted to <code><a href="/reference/androidx/compose/animation/core/AnimationVector.html">AnimationVector</a></code> to animate. <code><a href="/reference/androidx/compose/animation/core/VectorizedAnimationSpec.html">VectorizedAnimationSpec</a></code> describes how the converted <code><a href="/reference/androidx/compose/animation/core/AnimationVector.html">AnimationVector</a></code> should be animated. E.g. The animation could simply interpolate between the start and end values (i.e.<code><a href="/reference/androidx/compose/animation/core/TweenSpec.html">TweenSpec</a></code>), or apply spring physics to produce the motion (i.e. <code><a href="/reference/androidx/compose/animation/core/SpringSpec.html">SpringSpec</a></code>), etc)</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/TwoWayConverter.html">TwoWayConverter</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V> converter</code></td> |
| <td> |
| <p>converts the type <code><a href="/reference/androidx/compose/animation/core/KeyframesSpec.html">T</a></code> from and to <code><a href="/reference/androidx/compose/animation/core/AnimationVector.html">AnimationVector</a></code> type</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </div> |
| </body> |
| </html> |