Skip to content

Commit

Permalink
added splashscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 26, 2024
1 parent aa70615 commit 2f50899
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composeApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:hardwareAccelerated="true"
android:enableOnBackInvokedCallback="true"
android:appCategory="news"
android:theme="@style/AppTheme">
android:theme="@style/SplashScreenTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.lifecycleScope
import com.arkivanov.decompose.DefaultComponentContext
Expand Down Expand Up @@ -41,6 +42,7 @@ class MainActivity : AppCompatActivity() {
@OptIn(ExperimentalDecomposeApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()

WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()
Expand Down
10 changes: 10 additions & 0 deletions composeApp/src/androidMain/res/drawable/splash_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/ic_launcher_background" />

<item>
<bitmap android:gravity="bottom"
android:src="@drawable/ic_launcher_foreground" />
</item>
</layer-list>
12 changes: 12 additions & 0 deletions composeApp/src/androidMain/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@
<item name="isLightTheme">true</item>
<item name="android:isLightTheme" tools:targetApi="q">true</item>
</style>

<style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/ic_launcher_background</item>
<item name="android:windowSplashScreenBackground" tools:targetApi="s">@color/ic_launcher_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@drawable/ic_launcher_foreground</item>
<item name="windowSplashScreenIconBackgroundColor">@color/ic_launcher_background</item>
<item name="android:windowSplashScreenIconBackgroundColor" tools:targetApi="s">@color/ic_launcher_background</item>
<item name="windowSplashScreenAnimationDuration">500</item>
<item name="android:windowSplashScreenAnimationDuration" tools:targetApi="s">500</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
</resources>

0 comments on commit 2f50899

Please sign in to comment.