Android fragments LottieAnimation未在片段内运行

Android fragments LottieAnimation未在片段内运行,android-fragments,android-activity,android-animation,lottie,lottie-android,Android Fragments,Android Activity,Android Animation,Lottie,Lottie Android,我有一个给评级的明星动画,我在我的片段中创建了三个这样的LottieAnimationView,以便重用。当我从片段的onCreate()方法内部运行lottie动画时,它甚至不会启动(我使用的是支持片段)。如果动画位于活动中而不是片段中,则完全相同的代码将运行动画。这是我的密码 mLottieStarView1 = findViewById(R.id.rating_lottie_star_1); //LottieView starLayout1 = findViewById(

我有一个给评级的明星动画,我在我的片段中创建了三个这样的LottieAnimationView,以便重用。当我从片段的
onCreate()
方法内部运行lottie动画时,它甚至不会启动(我使用的是支持片段)。如果动画位于
活动
中而不是片段中,则完全相同的代码将运行动画。这是我的密码

    mLottieStarView1 = findViewById(R.id.rating_lottie_star_1);  //LottieView
    starLayout1 = findViewById(R.id.rating_star_layout_1); //Enclosing LinearLayout
    mValueAnimator1 = ValueAnimator.ofFloat(0f, 1f).setDuration(1500);

    //Create animation update methods
    mValueAnimator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {  //Star 1
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mLottieStarView1.setProgress((Float) valueAnimator.getAnimatedValue());
        }
    });

    //Set listener on enclosing layout to run animation on touch
    starLayout1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mLottieStarView2.setProgress(0f);
            mLottieStarView3.setProgress(0f);
            mValueAnimator1.start();
        }
    });

确保将图像视图设置为
isClickable=true
xml中的
isFocusable=true

使用
lottieView.playamation()启动乐蒂动画方法,对于取消单击,请尝试以下操作

if(lottieTest.getFrame() == lottieTest.getMaxFrame()) {
   lottieTest.setFrame(1);
}

这里使用AndroidX、FragmentActivity和ViewPager2也一样