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
.json 文件它应该在 app/src/main/assets/ 文件夹下,不需要asset.open
只需在你的情况下放置setAnimation(json_filename)
它应该是setAnimation("failanimation.json")
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.