Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the shape of the splash screen icon in Android 12?

I'm in the process of customizing the new splash screen that is being implemented in Android 12.
I have been able to change the icon to the one I want using

"< item name="windowSplashScreenAnimatedIcon">@drawable/...</item >"

but because it is a word and not an icon that will fit in the circular shape, but word has stretched to fit in the circle. Is there a way to change the shape or size of the icon or icon background so this doesn't happen?

like image 771
emmastone Avatar asked Aug 06 '21 20:08

emmastone


1 Answers

Update

If you use a vector drawable as the windowSplashScreenAnimatedIcon, then you can use the group to change the size which works well in most cases. Just wrap all the path of your vector drawable in group as shown below.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="1024"
    android:viewportHeight="1024">

    <group
        android:pivotX="512"
        android:pivotY="512"
        android:scaleX="0.50"
        android:scaleY="0.50">
        
        <path
        android:fillColor="@color/whiteColor"
        android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92s2.92,-1.31 2.92,-2.92 -1.31,-2.92 -2.92,-2.92z"/>

    </group>
</vector>

You can adjust the scaleX and scaleY as per your needs. Make sure that the pixotX and pivotY are exactly the half of viewportWidth and viewportHeight so that the scaling happens from the center.

Old Answer

There is no direct way to change the size of the icon but you can follow the below approach to add padding to the icon so that it is not cropped. Do keep in mind that this is not the best approach and is just a temporary fix.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="44dp"
        android:drawable="@drawable/ic_splash_logo"
        android:left="44dp"
        android:right="44dp"
        android:top="44dp"
        />
</layer-list>

Set this file as the windowSplashScreenAnimatedIcon. You can adjust the padding to suit your needs.

like image 151
Mehul Kanzariya Avatar answered Sep 28 '22 22:09

Mehul Kanzariya