Home > front end >  New Splash screen is shown cut in a cyrcle shape
New Splash screen is shown cut in a cyrcle shape

Time:11-09

I'm trying to replace my old activity based splash screen in my Android app with the new enter image description here

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);
    ...

CodePudding user response:

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.

CodePudding user response:

This happens when I run my app on an emulator 30s but when I run it on a physical device it show well. Looking at your code and comment above, is it really required you implement the image from the styles/Res ?... I recommend you create the imageView in your splash_screen.xml

  • Related