2

The recommended method of creating a splash screen while the app loads is to specify a theme in the manifest for the launch activity that uses a layer-list as a window background.

How can this method be extended to support multiple user themes (e.g. light, dark, pink, etc.) so that the splash screen background can be the appopriate colour?

I have attempted using styled attributes ?backgroundColour but the correct style isn't set when the initial themeing occurs. I have also tried overriding getTheme() in the launch activity but it receives the call after the splash screen is already displayed.

Is this possible to do in Android?

Rex Nihilo
  • 604
  • 2
  • 7
  • 16
Prof
  • 657
  • 1
  • 14
  • 24

1 Answers1

1

What you can do is to use initial activity with a background that use a color depends on the dark and light mode.

If you want to make your activity look like a splash screen you can use the following code;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    super.onCreate(savedInstanceState);

    // Where this layout uses the icon on the center with a dynamic background color
    setContentView(R.layout.activity_start);

    // This is where you set theme colors to the status bars, etc.
    UtilTheme.changeThemeColors(TAB_COLOR_START, null, this);

    // Your logic
}
Berkay Turancı
  • 3,373
  • 4
  • 32
  • 45
  • This doesn't style the splash screen, it's just using another layout that it inflates isn't it? There's a white flicker that these types of solutions have. – Prof Apr 02 '21 at 19:46