adapter.addHeaderView(headerView, 0);
adapter.getHeaderLayout().setId(R.id.author_head_view);
recycleView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(@NotNull Rect outRect, @NotNull final View view, @NotNull final RecyclerView parent, @NotNull RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
if (view.getId() != R.id.author_head_view) {
int dLong = ScreenUtils.dip2px(AuthorActivity.this, 13);
int dShort = ScreenUtils.dip2px(AuthorActivity.this, 2);
int spanIndex = ((StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams()).getSpanIndex();
if (spanIndex == 0) {
outRect.left = dLong;
outRect.right = dShort;
} else {
outRect.left = dShort;
outRect.right = dLong;
}
}
}
});