Android Change Background Color

Android Change Background ColorAndroid screen navigation example using Activity and IntentAndroid WebView ExampleAndroid EditText TutorialAndroid Button onClickListener ExampleJQuery how to change background imageAndroid Button ClickAndroid Tutorial For BeginnersBest Android ApplicationsHow to change your IPHow to change facebook nameAspnet Listbox Selectedindexchanged problems and solutionDiv Background ImageHow to earn money with android phoneJquery Gridview Dropdownlist Selected Change Enable Disable ControlsAndroid install APK from computer applicationJQuery Select ChangeHow to remove android applicationsAndroid Market LoginChange Firefox Proxy Settingsremove android appsRemove Gmail account from AndroidJquery how to Change or add remove CSSHow to improve performance of Android phoneAndroid Screen SleepLearning JqueryHow to Enable WiFi on Android phoneJQuery On Click Change Div ContentAndroid browser remove safe searchAndroid phone with keyboard (Top Smart Phones)Turn your android phone into heart monitoring machine
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.

Tags:

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
Satalaj More+

I'm Satalaj.