我正在尝试实现Lottie Animation json。我有一个红色的图像视图,在它上面我想放一个蓝色的动画视图。他们需要合适的尺寸。问题是从右侧和左侧填充太高。所以我不知道如何使动画视图与图像相同。
Image how it suppose to looks like
我已尝试从这里Lottie animation padding
解决问题xml
<de.hdodenhof.circleimageview.CircleImageView
android:background="@color/colorAccent"
android:id="@+id/hot_first_item"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:src="@drawable/flame_red"
/>
<com.airbnb.lottie.LottieAnimationView
android:background="@android:color/holo_blue_bright"
android:id="@+id/lottieAnimationView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:lottie_loop="true"
app:lottie_autoPlay="true"
app:lottie_fileName="hot_round.json"/>
Java
void bind(int position) {
if (position == 0) {
LottieDrawable drawable = new LottieDrawable();
LottieComposition.Factory.fromAssetFileName(context, "hot_round.json",(composition -> {
drawable.setComposition(composition);
drawable.playAnimation();
drawable.setScale(0.13f);
lottieAnimationView.setImageDrawable(drawable);
}));
} else {
mSecondItemImage.setImageResource(mUsersList.get(position));
}
}