Android simple white background without gradient
I set the background of my android app to white and used a light theme to try and get a white background. I did this 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 light gray to white color gradient. I would like the background to be a simple solid white with no gradient. Is there a way to easily achieve this?
source to share
You have many different ways to do this. Just pick one .
Option 1
Set the background of each of your layouts to android:background="@android:color/white"
or android:background="#ffff"
.
Option 2
If you don't want to support this in your application, you can use android:background="@color/background"
then create a resource file with <color name='background'>#ffff</color>
.
Option 3
Another alternative is to create a file FrameLayout
that you always use in setContentView()
and that has its own background color (according to parameter 1), and then inflate other layouts within it.
Option 4
You can do this with Java code using layout.setBackgroundColor(Color.rgb(255, 255, 255));
.
Option 5
Expand 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"
source to share