ysxy

添加依赖
compile \'com.airbnb.android:lottie:2.2.0\'

进入下载Demo

将项目中的示例中的assets文件夹拷贝到自己新建的项目

https://github.com/airbnb/lottie-android

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

  <com.airbnb.lottie.LottieAnimationView
      android:id="@+id/lav_show"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      app:lottie_fileName="Hello World.json"
      app:lottie_loop="true"
      app:lottie_autoPlay="true"
      />

</RelativeLayout>



public class MainActivity extends AppCompatActivity {
  private LottieAnimationView lav_show;
  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    lav_show = (LottieAnimationView) findViewById(R.id.lav_show);

    LottieComposition.Factory.fromAssetFileName(this, "City.json",
        new OnCompositionLoadedListener() {
          @Override public void onCompositionLoaded(@Nullable LottieComposition composition) {
            lav_show.setComposition(composition);
          }
        });
  }
}

分类:

技术点:

相关文章:

  • 2021-10-09
  • 2022-01-01
  • 2021-12-09
  • 2022-02-18
  • 2021-12-07
  • 2021-08-21
  • 2021-07-04
猜你喜欢
  • 2021-07-22
  • 2022-02-12
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案