LoginSignup
29
23

More than 3 years have passed since last update.

Lottie-Androidで素晴らしいアニメーション試す

Last updated at Posted at 2018-08-03

Lottie-Androidとは

Airbnbが開発したアニメーションを簡単に表示できるライブラリ

詳しくは公式ページを参照
https://airbnb.design/lottie/

AndroidのGithubはここ
https://github.com/airbnb/lottie-android

導入

app/gradleに以下を追加

    implementation 'com.airbnb.android:lottie:2.5.5'

アニメーションファイルは以下サイトに山ほどあるんで、好きなアニメーションのjsonをダウンロードする
LottieFiles - https://www.lottiefiles.com/

jsonをresに配置する

自分はrawディレクトリを作ってそこに置いた

スクリーンショット 2018-08-03 13.16.34.png

実装

自動再生させたければレイアウトxmlに追加するだけで済む

    <com.airbnb.lottie.LottieAnimationView
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:lottie_autoPlay="true"
        app:lottie_loop="true"
        app:lottie_rawRes="@raw/giftbox"
        />

たったこれだけ、素晴らしい

もちろんコードで実装することも可能(今回はやらないけど)

完成物

いろいろアニメーションを載っけてみた

感想

LottieFilesのというサイトから好きなアニメーションを選んで、簡単にアプリに導入できるのは素晴らしい

そしてアニメーションのクオリティが高い!

作ろうと思えばアニメーションは自分で作れるらしい

気になった事

いくつかアニメーションjsonがAndroid Studioにコピーするとビルドが失敗した

Android Studioがjsonを読み込めなかったのか、jsonが正しく書かれてないのか不明...

また、Android Studioのレイアウトxmlを修正する際にエディタがすっごく重たくなる気がする。

これはAndroid Studio 3.2 Beta 5だからなんだろうか...

使用コード

ikemura23/Android-Kotlin-Lab at Lotties https://github.com/ikemura23/Android-Kotlin-Lab/tree/Lotties

29
23
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
29
23