Add splash screen

This commit is contained in:
Super12138 2024-09-08 11:47:59 +08:00
parent 7954ea4a4f
commit 028a43474b
6 changed files with 23 additions and 1 deletions

View file

@ -69,6 +69,7 @@ dependencies {
// Android X
implementation(libs.androidx.core)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.core.core.splashscreen)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.activity)
implementation(libs.androidx.activity.ktx)

View file

@ -13,7 +13,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ToDo"
android:theme="@style/Theme.ToDo.Starting"
tools:targetApi="35">
<activity

View file

@ -4,6 +4,7 @@ import android.app.ComponentCaller
import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import cn.super12138.todo.R
@ -15,6 +16,7 @@ import cn.super12138.todo.views.fragments.welcome.WelcomeFragment
class MainActivity : BaseActivity<ActivityMainBinding>() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
if (!GlobalValues.welcomePage) {

View file

@ -0,0 +1,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="70dp"
android:height="70dp"
android:drawable="@drawable/ic_launcher"
android:gravity="center" />
</layer-list>

View file

@ -61,6 +61,16 @@
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
</style>
<style name="Theme.ToDo.Starting" parent="Theme.SplashScreen">
<!-- Splash Screen 背景颜色 -->
<item name="windowSplashScreenBackground">#0061A4</item>
<!-- Splash Screen 图标 -->
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<!-- 应用默认主题 -->
<item name="postSplashScreenTheme">@style/Theme.ToDo</item>
</style>
<style name="AppPreferenceThemeOverlay" parent="@style/PreferenceThemeOverlay">
<item name="switchPreferenceCompatStyle">@style/AppSwitchPreference</item>
</style>

View file

@ -14,6 +14,7 @@ recyclerview = "1.3.2"
fragment = "1.8.3"
fragmentKtx = "1.8.3"
roomRuntime = "2.6.1"
splashScreen = "1.2.0-alpha02"
# Material
material = "1.13.0-alpha05"
# Fast Scroll
@ -33,6 +34,7 @@ ksp = "2.0.20-1.0.25"
# Android X
androidx-core = { group = "androidx.core", name = "core", version.ref = "core" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-core-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashScreen" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activityKtx" }