RecyclerView添加行間距

firstOffset = mContext.getResources().getDimensionPixelOffset(R.dimen.recyclerview_firstposition_offset);ide

lastOffset = mContext.getResources().getDimensionPixelOffset(R.dimen.recyclerview_lastposition_offset);spa

public class BaseItemDecoration extends ItemDecoration{get

@Overrideit

public void getItemOffsets(Rect outRect, View view,io

RecyclerView parent, State state) {ast

// TODO Auto-generated method stubclass

super.getItemOffsets(outRect, view, parent, state);im

                        //if(parent.getChildPosition(view) == 0){recyclerview

//        outRect.set(0, firstOffset, 0, 0);di

        //}else if(parent.getChildPosition(view) == (mData.size() - 1)){

         // outRect.set(0, 0, 0, lastOffset);

                 //}

                            outRect.set(0, 0, 0, lastOffset);//每一個item的底部偏移

}

}

相關文章
相關標籤/搜索