Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window background is clipped by status bar

I am setting image as window background:

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

It works for tablets and fullscreen windows:

enter image description here

but on the handset it is clipped by status bar:

enter image description here

Is this the way things work? How do I avoid it? Of course, I could set the background for each layout, but I want to know if this the only way to solve the problem.

like image 849
Andrii Chernenko Avatar asked Jan 18 '13 11:01

Andrii Chernenko


Video Answer


1 Answers

My solution to this problem (at least for phones) was to create a xml drawable with the statusbar height as the top offset

e.g. drawable/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 on the bottom though.

EDIT: edited the answer to use a single xml drawable, as sugested by Aleksejs Mjaliks

like image 116
Zarokka Avatar answered Sep 28 '22 11:09

Zarokka