LoginSignup
0
1

More than 1 year has passed since last update.

MotionLayoutの例を試してみる(キーフレームの循環)

Last updated at Posted at 2022-05-21

前回はキーフレームの補間をやりました。

キーフレームの補間

公式リファレンス

リンク先に公式サンプルがあります。
キーフレームの循環

<KeyFrameSet>
  <KeyCycle
    android:translationY="0dp"
    motion:framePosition="100"
    motion:motionTarget="@id/button"
    motion:waveOffset="0"
    motion:wavePeriod="0"
    motion:waveShape="sin" />
  <KeyCycle
    android:translationY="200dp"
    motion:framePosition="20"
    motion:motionTarget="@id/button"
    motion:waveOffset="0"
    motion:wavePeriod="1"
    motion:waveShape="sin" />
  <KeyCycle
    android:translationY="0dp"
    motion:framePosition="0"
    motion:motionTarget="@id/button"
    motion:waveOffset="0"
    motion:wavePeriod="0"
    motion:waveShape="sin" />
</KeyFrameSet>

KeyCycle

framePositionとmotionTargetに関しては前回に書いたので今回は説明しないです。

android:translationY今回は上下の振れ幅の大きさになります。

waveShapeは『sin | square | Triangle | sawtooth | reverseSawtooth | cos | bounce』を設定できます。これは波形の形を決めています。

wavePeriodは波形のループする回数です。今回は1なので上下のアニメーションが1回です。

以上となります。
これでキーフレーム関係は終わりです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1