Here is my Lottie animation code:
public class Splash extends AppCompatActivity {
ImageView logo,splashImg;
LottieAnimationView lottieAnimationView;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
logo = findViewById(R.id.logo);
splashImg = findViewById(R.id.img);
textView = findViewById(R.id.Motto);
lottieAnimationView = findViewById(R.id.lottie);
splashImg.animate().translationY(-2800).setDuration(1000).setStartDelay(4000);
logo.animate().translationY(1850).setDuration(1000).setStartDelay(4000);
textView.animate().translationY(1800).setDuration(1000).setStartDelay(4000);
lottieAnimationView.animate().translationY(1800).setDuration(1000).setStartDelay(4000);
}
}
And Now I want to go to another Activity, How do I do it??
2
Answers
You can use the
Handler
class for this purpose and then navigate to your second or newActivity
subclass by usingIntent
like so. In short this code will navigate to the other activity by waiting for 2000 milliseconds or 2 seconds which can be customised. Maybe you can add set it according to when your animation is done by selecting the duration of largest among allAnother clean approach would to be add an
AnimationListener
and as soon as the animation completes just fire anIntent
to start the otherActivity
You can find how to use
AnimationListener
specially forLottie
herePlease check this code: