How to remove the shadow above the app bar?

brettbrdls picture brettbrdls · Feb 29, 2016 · Viewed 7.7k times · Source

I'd like to make the status bar transparent by adding <item name="android:statusBarColor">@android:color/transparent</item> to v21/styles.xml on style name="AppTheme.NoActionBar" but I keep getting a shadow above the app bar, is it possible to remove it?

EDIT: Ok I think the solution is to move the app bar occupying the status bar space and extending the app bar of an additional dp to match it size so my question is, is it possible to move or extend the app bar height upwards?

activity_search.xml

<android.support.design.widget.AppBarLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:theme="@style/MyMaterialTheme.AppBarOverlay">

     <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/MyMaterialTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_search"/>

enter image description here

Answer

Karol Żygłowicz picture Karol Żygłowicz · Mar 9, 2016

I believe this question is pointing to same problem Android appbarlayout elevation appears in status bar

Possible solutions:

Your root layout should have android:fitsSystemWindows="true" at all times, otherwise your UI will not draw behind status bar.

Now wrap the AppBarLayout inside another CoordinatorLayout which has

android:fitsSystemWindows="false".

This will prevent the shadow from overflowing into statusbar.