Reputation: 4259
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
Upvotes: 13
Views: 17485
Reputation: 249
This method will give the padding to the last position view
public class MyAdapter extends RecyclerView.Adapter<VH>{
public int getItemType(int position){
if(arrayList.size()-1==position){
return ITEM_TYPE;
}
return 0;
}
public MyHolder onBindViewHolder(MyHolder holder,int position){
if(getItemViewType(position)==ITEM_TYPE){
holder.itemView.setPadding(0,0,0,10);
}
}
Upvotes: -1
Reputation: 17085
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'
Upvotes: 8