Java 开始晚了

Java 开始晚了,java,android,xml,android-studio,Java,Android,Xml,Android Studio,我不知道为什么,但当我开始或回到我的活动,我有梯度设置为背景,它开始晚了3秒。 XML代码(我将3个渐变放在一个文件中): 任何帮助都将不胜感激 <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <ite

我不知道为什么,但当我开始或回到我的活动,我有梯度设置为背景,它开始晚了3秒。 XML代码(我将3个渐变放在一个文件中):

任何帮助都将不胜感激

 <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/gradient_1"
            android:duration="4000"/>
        <item android:drawable="@drawable/gradient_2"
            android:duration="4000"/>
        <item android:drawable="@drawable/gradient_3"
            android:duration="4000"/>
    </animation-list>
    ConstraintLayout constraintLayout = findViewById(R.id.layout);
    AnimationDrawable animationDrawable = (AnimationDrawable) constraintLayout.getBackground();
    animationDrawable.setEnterFadeDuration(2000);
    animationDrawable.setExitFadeDuration(4000);
    animationDrawable.start();