首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Lottie动画根本不显示

Lottie动画根本不显示
EN

Stack Overflow用户
提问于 2019-11-20 20:05:33
回答 2查看 5.3K关注 0票数 1

我的导入:

代码语言:javascript
复制
implementation "com.airbnb.android:lottie:3.2.2"

在我的splash_layout中:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/splash"/>

<com.airbnb.lottie.LottieAnimationView
    android:id="@+id/animation_view"
    android:layout_width="100dp"
    android:layout_height="100dp"
    app:lottie_fileName="logo_android.json"
    app:lottie_loop="true"
    app:lottie_autoPlay="true"
    app:lottie_imageAssetsFolder="demo"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"/>

在SplashActivity中:

代码语言:javascript
复制
private LottieAnimationView animationView;
(...)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash_layout);
    animationView=findViewById(R.id.animation_view);
    animationView.playAnimation();
(...)
}

我的图像文件夹在src/main/res/assets/demo中。logo_android.json文件位于src/main/assets

这样,动画根本不会显示。没有显示任何一张图像。怎样才能让动画工作起来?

如果重要的话,JSON文件看起来像这样:

代码语言:javascript
复制
{"v":"5.5.8","fr":25,"ip":0,"op":400,"w":800,"h":400,"nm":"logo_android","ddd":0,"assets":[{"id":"image_0","w":396,"h":51,"u":"images/","p":"img_0.png","e":0},{"id":"image_1","w":122,"h":215,"u":"images/","p":"img_1.png","e":0},(...)
EN

回答 2

Stack Overflow用户

发布于 2019-11-21 17:20:07

解决了它。

如果它可以帮助某人,您必须将图像放在src/main/assets/images中

票数 0
EN

Stack Overflow用户

发布于 2020-11-09 05:26:07

通过以下方式让它正常工作:

代码语言:javascript
复制
if(lottieTest.getFrame() == lottieTest.getMaxFrame()) {
   lottieTest.setFrame(1);
}

请参考this

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58953963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档