How to set the background for the whole application on Android?

In my application I have many layers and instead of setting a background image for each of them, I want to set the background once and for all. How can i do this?

+7
source share
2 answers

Take a look at Apply Theme to an Activity or application to apply a background image throughout the application.

+8
source

Add android:windowBackground to your theme:

 <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:windowBackground">@color/colorPrimaryDark</item> </style> 

And of course, make sure your manifest uses a theme for your application:

 <?xml version="1.0" encoding="utf-8"?> <manifest package="com.package.name" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest> 
0
source

All Articles