The android material design documentation suggests adding an 8 dp padding at the top and bottom of a list, and I personally like the idea and want to implement it. I am using the new RecyclerView
widget to accomplish the look of a simple list. The problem that I'm having is when I set the attributes: paddingTop
and paddingBottom
of my RecyclerView, the overscroll shadow which appears at the top and bottom of the list now has a padding too (and kind of looks bad and like an error). I've been reading that setting these attributes:
clipToPadding = false
scrollbarStyle = outsideOverlay
should do the trick for me, but it simply doesn't. The overscroll effect still begins with an 8 dp padding at the top and bottom of the screen and it really bugs me out. Am I doing something wrong here, or there is another solution for my problem? Any advice appreciated. Thx
RecyclerView is a ViewGroup , and by default, a ViewGroup clips it's children for padding, or in other words, it won't let the children view draw in the padding area. We can change this behavior easily by adding clipToPadding to the RecyclerView . Rerun the app, and you see the magic! Perfect Screen!
You can use clipToPadding for views that scroll. Say you have a listview for example and you having padding set on the top and bottom. Normally the padding is visible no matter which items are visible on the screen.
Adding clipToPadding
as false works on latest releases
android:clipToPadding="false"
I'm using recylerview
version
compile 'com.android.support:recyclerview-v7:22.2.1'
This is a known bug, will be fixed when RecyclerView is released.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With