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.setBackgroundColor(0xfff00000);
This is inside an OnClickListener
, but it just changes the background of the Button.
Just go to res/values/styles.edit the xml file to change the color of action bar.
Right click, and go to personalize - click background - solid color - and pick white. You should be in good shape!
android:background="" is the attribute used to set background for any Layout file. You can directly specify the value as HEX color code as we do for CSS files in HTML.
Try creating a method in your Activity
something like...
public void setActivityBackgroundColor(int color) { View view = this.getWindow().getDecorView(); view.setBackgroundColor(color); }
Then call it from your OnClickListener passing in whatever colour you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With