0

I'd like to add some padding to my recycler view so the status bar doesn't cover the first item. The problem is when I apply top padding, a solid white shows on top preventing the full screen experience.

enter image description here

Here is my layout:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/RecentVizzyView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="48dp" />

    <ProgressBar
        android:id="@+id/progressbar"
        android:layout_width="65dp"
        android:layout_height="65dp"
        android:layout_gravity="center"
        android:indeterminate="true"
        android:indeterminateTint="@color/lightGreen"
        android:indeterminateTintMode="src_atop" />

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

and I'm setting no limits flag to my screen:

getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
fullmoon
  • 8,030
  • 5
  • 43
  • 58

1 Answers1

1

Set android:clipToPadding="false" on your RecyclerView.

That will allow the paddingTop (and bottom, if you want), to be part of the scrollable part.

A better description is found here:
Android what does the clipToPadding Attribute do?

Moonbloom
  • 7,738
  • 3
  • 26
  • 38
  • I'd be surprised if that works, because clipToPadding have to be set on RecyclerView parent, not the RecyclerView itself. – ror Aug 24 '19 at 19:32
  • Thank you that fixed it :) I just added this to the above recyclerview and the list can scroll behind the notch now without the white thing. – fullmoon Aug 24 '19 at 19:33
  • @ror No, it has to go on the RecyclerView itself. The RV has the padding, and is a ViewGroup. clipToPadding tells the ViewGroups children that they can use the padding space to scroll. In this case, the children are the list elements in the RV. – Moonbloom Aug 24 '19 at 20:46