Martin
Martin

Reputation: 2904

Android 12 Splash screen icon

I want to use new Android 12 API for Splash Screen, but if I use my drawable icon inside theme for parameter windowSplashScreenAnimatedIcon, its stretched. How can I adjust size of that icon? My icon is not vector. I have to use png file.

Upvotes: 10

Views: 21981

Answers (2)

Lain
Lain

Reputation: 1

create 2 values directory

in values-v31

<style name="SplashScreenTheme" parent="Theme.SplashScreen">
    <item name="android:windowSplashScreenBackground">@color/color_121326
    </item>
    <item name="postSplashScreenTheme">@style/SplashScreen</item>
    <item name="android:windowSplashScreenAnimatedIcon">
        @drawable/ic_splash_center
    </item>
    <item name="splashScreenIconSize">@dimen/dp_100</item>
</style>

and in values-v33

<style name="SplashScreenTheme" parent="Theme.SplashScreen">
    <item name="android:windowSplashScreenBackground">@color/color_121326
    </item>
    <item name="postSplashScreenTheme">@style/SplashScreen</item>
    <item name="android:windowSplashScreenAnimatedIcon">
        @drawable/drawable_splash
    </item>
    <item name="splashScreenIconSize">@dimen/dp_100</item>
</style>

in drawable_splash

<item
    android:width="@dimen/dp_100"
    android:height="@dimen/dp_100"
    android:gravity="center">
    <bitmap android:src="@drawable/ic_splash_center" />
</item>

i find it works to resize icon above api33

Upvotes: -1

sergpetrov
sergpetrov

Reputation: 1714

Likely, you have to follow the Splash Screen dimensions. Google says:

  • App icon with an icon background: This should be 240×240 dp, and fit within a circle of 160 dp in diameter.
  • App icon without an icon background: This should be 288×288 dp, and fit within a circle of 192 dp in diameter.

enter image description here

Upvotes: 10

Related Questions