I want to change the background color of my Main-View (not a Button or a Text-View) just the real background which is usually black... I got this code:
view.
I just want to add my 2 cents. I had the same goal (to change the background color from the .java class). But none of the above methods worked for me.
Issue was, that I set the background color inside the layout .xml file with android:background="@color/colorGray":
So I just deleted particular line:
Now I (you) can set the color from the code with:
getWindow().getDecorView().setBackgroundColor(Color.GRAY);