Android draw under status bar

1k views Asked by At

I am working on designing an app on Android Lollipop that draws a Navigation Drawer under the status bar. I have been partially successful with this. I can get the drawer to draw under the status bar, but not the contents of the drawer.


Screenshot of device with drawer layout


I do not have any padding on the drawer, and I have no margin on the TextView. Here is my layout.xml file:

<android.support.v4.widget.DrawerLayout
  android:id="@+id/drawer_layout"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".HomeActivity"
  android:fitsSystemWindows="true">

   <!--window content -->
  <LinearLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true">

    <Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="56dp"
      android:background="#FF5722"
      android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"
      android:minHeight="?android:attr/actionBarSize"
      android:elevation="4dp"/>

    <android.support.v7.widget.RecyclerView
      android:id="@+id/grid_recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scrollbars="vertical"/>

  </LinearLayout>

  <!-- The navigation drawer -->
  <RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="320dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#f5f5f5"
    android:elevation="16dp"
    android:fitsSystemWindows="true">

    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Hello, Drawer!"
      android:fitsSystemWindows="true"/>

  </RelativeLayout>

</android.support.v4.widget.DrawerLayout>


I have already tried putting a negative top padding on the TextView, but it is just clipped underneath the status bar, and I just see the drawer background. How can I get the children of the drawer element to draw under the status bar?

Thank You

1

There are 1 answers

0
vcapra1 On

As it turns out, I thought android:fitsSystemWindows="true" did the opposite of what it actually does, so just remove that from all of the views and it should work perfectly. Thanks to +der Android Pro on Google Plus.