I have a question for the ones of you who have experience using lottie json files. I am not so experienced using lottie so I thought maybe I am missing some obvious knowledge. When I render my animation into a view, the animation object are placed in the center of the view like that
_____________________________________________
| |
| [animated object] |
|_____________________________________________|
Is there a way I can modify the json file to make the animated objects fit the whole view like that:
_____________________________________________
| |
| [a n i m a t e d o b j e c t s ]|
|_____________________________________________|
I have tried setting the view in the xml like that:
android:scaleType="centerCrop"
android:adjustViewBounds="true"
but it didn't work
I also tried to set a greater scale:
app:lottie_scale="2"
but I had no success. Thank you for your time!
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animationView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
app:lottie_autoPlay="true"
android:padding="10dp"
app:lottie_loop="true"
app:lottie_rawRes="@raw/your_json_file_here"/></RelativeLayout>
** Try this code. it's working **
Just treat it like any other view and use the setPadding programmatically.
LottieAnimationView btnHeart;
btnHeart.setPadding(-150, -150, -150, -150);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With