Home > Net >  How can I change the loading screen colour without "android:background"?
How can I change the loading screen colour without "android:background"?

Time:10-04

Before my app loads I can change the color of the loading screen using

<resources>
    <style name="Theme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <item name="android:background">#FF444444</item>
    </style>
</resources>

However, if I do this then I can no longer load the material design library's TimePickerView because it says Binary XML file line #57: Error inflating class com.google.android.material.timepicker.TimePickerView and, more importantly, Attempted to get ShapeAppearanceModel from a MaterialButton which has an overwritten background.

Once I remove the above android:background all is well. Except my loading screen is now white.

So, is there a way to change the loading screen colour without the above XML attribute in the hope that I can get material's TimePicker to work? Or perhaps another work around?

(I've found out how to disable the loading screen completely, but the second or so wait is not ideal.)

CodePudding user response:

Here are the possible solutions (the first solved it):

  1. Use android:windowBackground instead of android:background >> requires to use a resources color than a hardcoded one (i.e. @color/some_color)
  2. Use window.decorView.setBackgroundColor(some_color) right after setContentView() call
  3. Set both android:colorBackground & android:windowBackground to have the same color, and remove android:Background
  • Related