Android Change Background Color
You want to change the background color of Android layout. It can be set at design time or runtime. Let’s see we can change the color of layout dynamically.
View v = (View) findViewById(R.id.layout);
v.setBackgroundColor(color.background_light);
Complete code.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View v = (View) findViewById(R.id.layout);
v.setBackgroundColor(color.background_light);
}
Above program loads the screen with default color white. You can write the code on button click to change the color.