Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView clipToPadding = false

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

like image 673
Sandra Avatar asked Jul 23 '14 15:07

Sandra


People also ask

What is RecyclerView clipToPadding?

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!

What is clip to padding in Android?

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.


2 Answers

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' 
like image 171
Libin Avatar answered Sep 21 '22 21:09

Libin


This is a known bug, will be fixed when RecyclerView is released.

like image 26
yigit Avatar answered Sep 24 '22 21:09

yigit