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.
Set the background of each of your layouts to be android:background="@android:color/white"
or android:background="#ffff"
.
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>
.
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.
You can do it through Java code, using layout.setBackgroundColor(Color.rgb(255, 255, 255));
.
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"
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