Created
July 1, 2021 01:31
-
-
Save STAR-ZERO/f28d411401703e2e0d5e05d51771f02c to your computer and use it in GitHub Desktop.
androidx.core:core-splashscreen の雑サンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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