• This repository has been archived on 24/Aug/2021
  • Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android library for getting a nice and simple SlashScreen into your Android app

Android SplashScreen

Codacy Badge Android CI Android Arsenal API PRs Welcome

Android library for getting a nice and simple splash screen into your Android app.

Animated demo

Installation

Up to now, the library is only available on JitPack. Please add this code to your build.gradle file on project level:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

To load the library into your project, use this code in the build.gradle file within the app module:

  implementation 'com.github.ChilliBits:splash-screen:1.1.7'

Usage

To use the splash screen, paste this code to the beginning of the onCreate method of the launcher activity of your app. For better performance, we recommend to do this before setContentView().

SplashScreenBuilder.getInstance(this)
    .setVideo(R.raw.splash_animation)
    .setVideoDark(R.raw.splash_animation_dark)
    .setImage(R.drawable.app_icon)
    .show()

Tip: If you want to have a custom activity transition, you can call overridePendingTransition(R.anim.customEnterAnim, R.anim.customExitAnim) after dispatching .show() of the splash screen.

If you want to receive a result from the splash screen, you can override onActivityResult as following:

Kotlin

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == SplashScreenBuilder.SPLASH_SCREEN_FINISHED) {
        if (resultCode == Activity.RESULT_OK) {
            //SplashScreen finished without manual canceling
        } else if (resultCode == Activity.RESULT_CANCELED) {
            //SplashScreen finished through manual canceling
        }
    }
}

If you want to have a look onto a implemented example in Kotlin, look at the MainActivity.kt file.

Java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SplashScreenBuilder.SPLASH_SCREEN_FINISHED) {
        if (resultCode == RESULT_OK) {
            //SplashScreen finished without manual canceling
        } else if(resultCode == RESULT_CANCELED) {
            //SplashScreen finished through manual canceling
        }
    }
}

If you want to have a look onto a implemented example in Java, look at the MainActivity.java file.

You can customize the appearance of the SplashScreen using following arguments when building the Activity with SplashScreenBuilder:

Builder method Description of functionality
setVideo(int res_id) Sets the animation video of the SplashScreen. You have to pass this argument, otherwise the app will get an error.
setVideoDark(int res_id) Set the animation video of the Splash Screen for the dark theme.
setImage(int res_id) Sets the image of the SplashScreen, which is displayed when the animation has ended. You have to pass this argument, otherwise the app will get an error.
setTextFadeInDuration(int millis) You can call this method to set the duration of the fade in animation of the title and the subtitle.
setTitle(String title) This method replaces the name of your app, which is the default title of the SplashScreen, with a custom string.
setSubtitle(String title) This method replaces the default subtitle, with a custom string.
skipImage(boolean skip) This opens the ability to skip the image after the video.
skipVideo(boolean skip) This opens the ability to skip the video and display the image directly

Thank you for using the SplashScreen library!

Β© ChilliBits 2018-2021 (Designed and developed by Marc Auberer)