6

I know that I can assign background color to individual views in layout.xml files. The bg color of a root layout of, say, Activity is effectively the background color of this activity. But is there a way to set this color globally to the whole application so that all activities and fragments get it automatically? I'm using the Theme.AppCompat theme.

Or am I not supposed to alter the default grey color at all?

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • 1
    check it – D.J Sep 16 '16 at 12:36
  • 1
    The previous answer is not completely correct for a particular case, when you animate window transition (enter or exit), especially if you use scale animation (scale down (< 1.0) for x and/or y). Each activity is actually a window. So if there is no activity below the animated one, you'll see black borders while your activity will be scaled up to 1.0. I did not find a way to set application (not activity of window) background color globally, do you? – Mykola Melnyk Jan 13 '21 at 15:31
  • @MykolaMelnyk: I have come across this problem, but thank you very much for describing it and even giving an explanation. – Violet Giraffe Jan 13 '21 at 23:56

1 Answers1

14

In styles file in base application theme add below mentioned line for all values folder in

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="android:windowBackground">@android:color/white</item>
</style>
Preetika Kaur
  • 1,991
  • 2
  • 16
  • 23