SJS SJS - 1 year ago 163
Android Question

How to set background color of an Activity to white programmatically?

How can I set the background color of an Activity to white programatically?

Answer Source

Get a handle to the root layout used, then set the background color on that. The root layout is whatever you called setContentView with.


  // Now get a handle to any View contained 
  // within the main layout you are using
  View someView = findViewById(;

  // Find the root view
  View root = someView.getRootView();

  // Set the color
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download