Background background is trimmed by status bar

I set the image as the background of the background:

<style name="AppTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:windowBackground">@drawable/bg_window</item> </style> 

It works for tablets and full screen windows:

enter image description here

but on the handset it is truncated by the status line:

enter image description here

Does this work? How to avoid this? Of course, I could set a background for each layout, but I want to know if this is the only way to solve the problem.

+7
source share
2 answers

My solution to this problem (at least for phones) was to create an xml that can be aligned with the status height as top offset

eg. draw / window _background.xml:

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:top="25dp"> <bitmap android:src="@drawable/some_background" /> </item> </layer-list> 

This will not work if the status bar is at the bottom.

EDIT: edited the answer for using a single xml drawing, as Aleksejs Mjaliks said

+3
source

Try this as follows.

 <style name="AppTheme" parent="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"> <item name="android:windowBackground">@drawable/bg_window</item> </style> 

:)

+2
source

All Articles