Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android KitKat : All my app content appears behind the ActionBar and StatusBar after changing StatusBar color

I've created a separate xml style file targeting KitKat and I've managed to change the color of the status bar. The only side-effect as seen on the picture, all the content is now moved up beneath the status bar. My question is how can I change the color of the status bar without overlaying this or how can I know the exact top margin I need to put on my content so its starts after the ActionBar and not beneath. Of course I need this to behave as expected on all screen sizes and densities. Thank you

Navigation drawer and all content appears beneath the ActionBar and Status Bar

values-v19/styles.xml

<style name="ThemeSelector" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBar</item>

        <item name="android:windowTranslucentStatus">true</item>
</style> 
like image 595
Speed Demon Avatar asked Dec 26 '13 11:12

Speed Demon


2 Answers

You should add the following to the top of the view(s)

android:paddingTop="?android:attr/actionBarSize"

If you're using the Support Library for the action bar, you need to remove the android: prefix

android:paddingTop="?attr/actionBarSize"

By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.

like image 127
need1milliondollars Avatar answered Oct 06 '22 09:10

need1milliondollars


EDITED

You can add

android:fitsSystemWindows="true"

in your XML File

like image 32
Tomas K Avatar answered Oct 06 '22 10:10

Tomas K