Home > Enterprise >  Splash screen - Displace logo from screen's center in Android 12
Splash screen - Displace logo from screen's center in Android 12

Time:09-16

I'm using the Android's new splash screen API, and I see a limitation in this new API. I want to place the logo above the center line without compromising the size of the logo in the splash screen (This is a requirement for my app's UX). Also my logo is square.

Is there any way to do this in the new API, or I have to go the old way. Will there be any problem because the new API docs says

If you have previously implemented a custom splash screen in Android 11 or lower, you'll need to migrate your app to the SplashScreen API to ensure that it displays correctly in Android 12 and higher. For instructions, see Migrate your existing splash screen implementation to Android 12.

Visually describe

CodePudding user response:

From what I've understood:

Sadly, you cannot achieve this desired outcome with the new API, and this new API will be called for Android 12 .

If you really want this, you should implement the new one without using the compat library (using the Splash Screen API directly), to avoid showing it to Android <= 11 at the same time that you will need to prevent the old one from rendering when Android >= 12, to avoid passing through two different splash screens in this case.

But I think it would be nice to understand if this divergent experience will be okay. If new Android versions are pushing this default behaviour, more and more devices will not see your desired outcome as time passes. Sad that they are not giving more freedom to this, I hope they change it in the future.

CodePudding user response:

By default, this is not supported; it's just layout_gravity="center".
One still could change splash_screen_view.xml and/or styles.xml.
Unless building from source, there is no way to change that XML.


git clone https://github.com/androidx/androidx.git
cd androidx/core

Project androidx/core/buildSrc needs Gradle 7.5 to build and buildscript needs repositories:

repositories {
    maven { url 'https://jitpack.io' }
    gradlePluginPortal()
    mavenCentral()
    google()
}

With androidGradlePlugin = "7.2.2" it still gets stuck in buildSrc with :plugins:build. Beside that broken androidx.inspection.gradle.InspectionPlugin, this is how to produce a custom build with an alternate XML layout. Fixing the build wasn't the question.

CodePudding user response:

I think its not possible with your way

  • Related