2
votes

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?

1
Can't you just have a different drawable for the night scenario?Henry Twist
@HenryTwist Yeah that works for system themes but not for user themesProf
What do you mean by user themes?Henry Twist
@HenryTwist A theme set by the user and saved in the SharedPreferences. Normally, without the splash screen, this theme would be selected before setContentViewProf
I've done that now, thank you.Prof

1 Answers

1
votes

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
}