Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the background of the android application?

I want to change the background of my App's Activity.

Now that is available in black I want to change that with some images or themes.

like image 516
Krishna Avatar asked Mar 29 '11 23:03

Krishna


1 Answers

Add a android:theme="@style/Theme.AppTheme attribute to your application tag in the manifest file with the theme you want to use. This will prevent the default "black" background to be drawn if you only set a background in your Activity/Fragment layout file.

You declared it in a style.xml file.

<?xml version="1.0" encoding="utf-8"?>
<resources>    
<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@style/Theme">
<!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
-->
</style>
</style>
    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:windowBackground">@drawable/custom_background</item>
    </style>

</resources>

AndroidManifest.xml file

...
<application
    android:name="@string/app_name"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppTheme">
...
like image 69
TouchBoarder Avatar answered Oct 18 '22 03:10

TouchBoarder