Home > OS >  kotlin android problem on animation loading in lottie
kotlin android problem on animation loading in lottie

Time:06-09

i want load animation from json file ... and json file is in assets .. i'm facing this problem

binding.animationView.setAnimation(assets.open("failanimation.json"))

compiler showing red line on setAnimation

CodePudding user response:

.json file it should be under app/src/main/assets/ folder and no need to asset.open simply put setAnimation(json_filename) in your case it should be setAnimation("failanimation.json")

CodePudding user response:

Try this once-

Step 1 -Add your Lottie animation file in raw resource folder app

res > right-click > New > Folder > Raw Resource Folder

Step 2- XML code

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

Step 3 -

binding.animationView.setAnimation(R.raw.failanimation)
  • Related