I have set the background of my Android app to white and used the light theme to try and get a white background. I did so by setting the following attributes in the Manifest:
android:background="@android:color/white"
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
This gives me a white background but there is also a color gradient from light gray to white. I would like to have the background a plain solid white with no gradient. Is there some way of easily achieving this?
You've got a lot of different ways to do it. Just pick one, though.
Option 1
Set the background of each of your layouts to be android:background="@android:color/white"
or android:background="#ffff"
.
Option 2
If you don't want to maintain this across your app, you could use android:background="@color/background"
then make a resource file with <color name='background'>#ffff</color>
.
Option 3
Another alternative is to make a FrameLayout
file which you always use in setContentView()
and which has your background color (as per option 1), then inflate your other layouts within it.
Option 4
You can do it through Java code, using layout.setBackgroundColor(Color.rgb(255, 255, 255));
.
Option 5
Extend the theme and change its background:
<style name="AppTheme" parent="android:Theme.Light.NoTitleBar.Fullscreen">
<item name="android:background">@android:color/white</item>
<item name="android:windowBackground">@android:color/white</item>
<item name="android:colorBackground">@android:color/white</item>
</style>
Then, in your manifest,
android:theme="@style/AppTheme"