Reputation: 706
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?
Upvotes: 2
Views: 470
Reputation: 3459
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
}
Upvotes: 1