First Method
View someView = findViewById(R.id.randomViewInMainLayout);// get Any child View
// Find the root view
View root = someView.getRootView()
// Set the color
root.setBackgroundColor(getResources().getColor(android.R.color.red));
Second Method
Add this single line after setContentView(...);
getWindow().getDecorView().setBackgroundColor(Color.WHITE);
Third Method
set background color to the rootView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:id="@+id/rootView"
</LinearLayout>
Important Thing
rootView.setBackgroundColor(0xFF00FF00); //after 0x the other four pairs are alpha,red,green,blue color.