我有一个问题要问那些有使用 lottie json 文件经验的人。我使用 lottie 的经验不多,所以我想我可能缺少一些明显的知识。当我将动画渲染到 View 中时,动画对象会像那样放置在 View 的中心
_____________________________________________
| |
| [animated object] |
|_____________________________________________|
有没有一种方法可以修改 json 文件,使动画对象适合整个 View :
_____________________________________________
| |
| [a n i m a t e d o b j e c t s ]|
|_____________________________________________|
我试过像这样在 xml 中设置 View :
android:scaleType="centerCrop"
android:adjustViewBounds="true"
但是没用
我还尝试设置更大的比例:
app:lottie_scale="2"
但是我没有成功。 感谢您的宝贵时间!
最佳答案
<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>
** 试试这段代码。它的工作 **
关于android - Lottie 动画填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51553314/