Android Activity Background Image

Matthew picture Matthew · Jan 19, 2012 · Viewed 48.4k times · Source

How do I use a background image in an Activity theme/style?

If I do this using a colour:

<style name="CustomTheme" parent="android:Theme.Light">
    <item name="android:windowBackground">@color/custom_theme_color</item>
</style>

It works correctly, but if I replace the line with:

<item name="android:windowBackground">@drawable/splash_image</item>

The image displays correctly, but all the content is squished into a tiny block in the top left corner of the screen. The shadow underneath the status bar is also cut off or messed.

I am using Mono for Android and the image is a valid nine-patch png.

Answer

VicVu picture VicVu · Jan 19, 2012

I also don't use themes, so in the layout of the activity I would add

android:background="@drawable/splash_image"