I'm trying to replace my old activity based splash screen in my Android app with the new Splashscreens API
So i've created a svg of my app logo, create the theme, and set in my MainActivity the installSplashScreen
but the logo in the Splashscreen looks like this when app is launched:
How could i fix that issue?
Here is what i've done style.xml:
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/colorAccent</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_visual_vector</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
Manifest:
<activity
android:name=".MainActivity"
android:theme="@style/Theme.App.Starting"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
MainActivity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SplashScreen.installSplashScreen(this);
setContentView(R.layout.activity_main);
...
What you can do is to wrap your icon in an inset drawable so that it is drawn inside the circle.
For example, create a drawable/splash_inset.xml
resource:
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_visual_vector"
android:insetLeft="72dp"
android:insetRight="72dp"
android:insetTop="72dp"
android:insetBottom="72dp"/>
The actual inset values depend on your image and its aspect ratio, using 72dp
here on all edges as an example.
Then apply this drawable as your windowSplashScreenAnimatedIcon
.