21

I want to add translucent statusbar and navigation to my app (for kitkat) and on most places it works well.

I have a theme with:

    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:windowTranslucentStatus">true</item>

and in my layouts I have android:fitsSystemWindows="true"

For normal activities this works fine, but I have two activities that make trouble. -> The content is shown behind the statusbar and my actionbar.

One of them is the PreferenceActivity were I fixed it by adding findViewById(android.R.id.list).setFitsSystemWindows(true);

The second is an Activity with ActionBar.NAVIGATION_MODE_TABS and there I can't find the right target for the setFitsSystemWindows(true) call.

I tried with findViewById(android.R.id.content) and findViewById(android.R.id.tabcontent). I also tried to add the xml attribute to the layout of my fragment but no success.

Markus
  • 3,225
  • 6
  • 35
  • 47
Dodge
  • 8,047
  • 2
  • 30
  • 45
  • No answer here but a question. In your preference activity did you make the status bar the same color as your actionbar? I'm trying to figure out how to do this without making the whole PreferenceActivity the same color. – Jared Rummler Apr 29 '14 at 21:49
  • as i never got a solution to this problem i decided to not change the statusbar at all (for now). so i have no idea how you could achieve this, sorry. – Dodge May 01 '14 at 10:11
  • did you found the solution? please share! – Matias Elorriaga Jul 27 '14 at 00:49
  • I found this, hope it helps : [https://github.com/Takhion/android-extendedactionbar](https://github.com/Takhion/android-extendedactionbar) – Saif C Jul 27 '14 at 15:19
  • So I ended up using PreferenceFragment and SystemBarTintManager and it works fine. https://github.com/jgilfelt/SystemBarTint – Jared Rummler Aug 07 '14 at 01:51
  • Is the android:fitsSystemWindows in your app Theme? Try putting it in there. –  Aug 21 '14 at 13:28

1 Answers1

2

Add a 25 dp paddingTop on your toolbar

alvarlagerlof
  • 1,516
  • 1
  • 18
  • 27
  • nice hack. Don't forget to adjust the height of your toolbar in case you are using ?android:attr/actionBarSize which is 56 dp, so the final height would be 56 + 16dp == android:layout_height="72dp" – vanomart Oct 31 '16 at 20:16