Android - Fadeout animation for splash screen

前端 未结 3 509
情书的邮戳
情书的邮戳 2021-02-04 13:39

I want to add fadeout animation for my splash screen, that is while closing the splash screen I want to bring the fadeout animation effect.

Here are the codes which I ha

3条回答
  •  没有蜡笔的小新
    2021-02-04 14:22

    If you're using a separate Activity for your splash screen, you can do the overridePendingTransition call that you've noted is available in Android 2+ only. You can choose to have apps that are built for 2+ do the transition and previous versions simply do the default transition:

    try {
        Method method = Activity.class.getMethod("overridePendingTransition", new Class[]{int.class, int.class});
        method.invoke(youractivity, inanimation, outanimation);
    } catch (Exception e) {
        // Can't change animation, so do nothing
    }
    

    It's better to have your splash screen a part of your main Activity (see this example). When the splash screen is part of your main activity, you can simply assign the animation to the splash screen layout.

提交回复
热议问题