How to change background color in android app
You can also use
android:background="#ffffff"
in your xml layout or /res/layout/activity_main.xml
, or you can change the theme in your AndroidManifest.xml by adding
android:theme="@android:style/Theme.Light"
to your activity tag.
If you want to change the background dynamically, use
YourView.setBackgroundColor(Color.argb(255, 255, 255, 255));
You need to use the android:background property , eg
android:background="@color/white"
Also you need to add a value for white in the strings.xml
<color name="white">#FFFFFF</color>
Edit : 18th Nov 2012
The first two letters of an 8 letter color code provide the alpha value, if you are using the html 6 letter color notation the color is opaque.
Eg :
Simplest way
android:background="@android:color/white"
No need to define anything. It uses predefined colors in android.R
.