Skip to content

Instantly share code, notes, and snippets.

@STAR-ZERO
Created July 1, 2021 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save STAR-ZERO/f28d411401703e2e0d5e05d51771f02c to your computer and use it in GitHub Desktop.
Save STAR-ZERO/f28d411401703e2e0d5e05d51771f02c to your computer and use it in GitHub Desktop.
androidx.core:core-splashscreen の雑サンプル
class MainActivity : AppCompatActivity() {
private val viewModel: MainViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen() // ★ SplashScreenを適用
setContentView(R.layout.activity_main)
splashScreen.setKeepVisibleCondition {  // ★ ここでtrueを返してる間はSplashScreenが表示されたまま
viewModel.isReady().not()
}
}
}
<style name="Theme.AppSplashScreen" parent="Theme.SplashScreen">
<item name="postSplashScreenTheme">@style/Theme.MyApplication</item> <!-- SplashScreen表示後のTheme -->
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_round</item> <!-- SplashScreenアイコン -->
<item name="windowSplashScreenBackground">@color/white</item> <!-- SplashScreenの背景 -->
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment