2

I created a new project with a Tabbed Activity and navigation style Action Bar Tabs.

The MainActivity's default layout is as follows on which i swipe from the TabLayout as follows:

enter image description here

After swiping all the way up it looks like this: The ToolBar and StatusBar are overlapping!

enter image description here

Questions:

Is this the expected behavior? Shouldn't the scrolling be disabled or if enabled, the toolbar should hide (e.g. whatsapp)? This default behavior appears buggy to me. Did i miss something that led to this?

And if this is the default expected behavior? how can do the following?

  • Disable the scrolling in CoordinatorLayout?
  • Hide the ToolBar when scrolling is enabled?

PS: Like i mentioned this is an unmodified new project (no changes from my end). If someone still needs the generated code I'll share.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • No, is not the expected behaviour. Looks like you have a transparency in the status bar. A color without alpha should fix it. That's just my guess, but would help to have the xml code and (if apply, if you are modifying something programmatically) the java code. – Sotti Feb 06 '16 at 16:57
  • nothing modified at all. just created the project and run. – Viral Patel Feb 06 '16 at 16:58
  • @Sotti which xml would you like me to share? – Viral Patel Feb 06 '16 at 16:59
  • Do you have enabled to window to draw status bar? – Nikola Despotoski Feb 06 '16 at 17:01
  • @NikolaDespotoski sorry did not understand. – Viral Patel Feb 06 '16 at 17:02
  • Which version of Android Studio are you using? I couldn't reproduce it because the tabbed activity in Android Studio 2 Beta 2 doesn't have the tabs... If you could share the code, it would help. – Sotti Feb 06 '16 at 17:06
  • @Sotti you have to select the `Action Bar Tabs` option from the dropdown in the last screen in the wizard when creating new project to get the tabs. Btw, I'm on the latest on stable channel i.e. 1.5.1 – Viral Patel Feb 06 '16 at 17:07
  • 2
    But, like I've said before, if you go to /v21/styles.xml you'll see in in your theme a line like this: @android:color/transparent. Instead of the transparent color, use the primaryDark color (replace that line bye @color/colorPrimaryDark). – Sotti Feb 06 '16 at 17:09
  • @Sotti Excellent! That was it. Working fine now. Thanks! (You might want to post an answer for this so that i can accept.) – Viral Patel Feb 06 '16 at 17:11

1 Answers1

3

Go to /v21/styles.xml and replace:

<item name="android:statusBarColor">@android:color/transparent</item>

by:

<item name="android:statusBarColor">@color/colorPrimaryDark</item>

The problem is that the status bar is transparent.

Note: By default, the status bar uses the primaryDarkColor if it's defined. So in this case, you could remove that line in order to use the primaryDarkColor as far as you keep this line...

<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

...in the values\styles.xml in your AppTheme.

Sotti
  • 14,089
  • 2
  • 50
  • 43