Skip to content

Commit

Permalink
Create animated splash screen for Android 12 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Nov 22, 2024
1 parent 9c83226 commit f850523
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
29 changes: 29 additions & 0 deletions app/src/main/res/drawable-v31/animated_splash_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="@drawable/splash_foreground">

<target android:name="translationGroup">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="translateX"
android:duration="500"
android:valueFrom="-10"
android:valueTo="21.5"
android:valueType="floatType"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</aapt:attr>
</target>
<target android:name="splashForeground">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="alpha"
android:duration="500"
android:valueFrom="0"
android:valueTo="1"
android:valueType="floatType"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</aapt:attr>
</target>

</animated-vector>
5 changes: 4 additions & 1 deletion app/src/main/res/drawable/splash_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:name="splashForeground"
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100"
android:gravity="center">
<group android:scaleX="0.57"
<group
android:name="translationGroup"
android:scaleX="0.57"
android:scaleY="0.57"
android:translateX="21.5"
android:translateY="21.5">
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/values-night-v31/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Base.SplashTheme" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenIconBackgroundColor">@color/dark_youtube_primary_color</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/animated_splash_foreground</item>
<item name="postSplashScreenTheme">@style/Base.DarkTheme</item>
</style>

</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Base.SplashTheme" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenIconBackgroundColor">@color/light_youtube_primary_color</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/animated_splash_foreground</item>
<item name="postSplashScreenTheme">@style/Base.LightTheme</item>
</style>

</resources>

0 comments on commit f850523

Please sign in to comment.