解决滑动不流畅问题
//其实添加第一句代码已经双歪歪了
mRecyclerView.setNestedScrollingEnabled(false);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setSmoothScrollbarEnabled(true);
layoutManager.setAutoMeasureEnabled(true);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setHasFixedSize(true);
Android GridLayoutManager 均分间距
mViewBinding.rv.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
int childAdapterPosition = parent.getChildAdapterPosition(view);
switch (childAdapterPosition%4) {
case 0:
outRect.left = 20;
outRect.right = 10;
break;
case 1:
outRect.left = 10;
outRect.right = 10;
break;
case 2:
outRect.left = 10;
outRect.right = 10;
break;
case 3:
outRect.left = 10;
outRect.right = 20;
break;
default:
break;
}
}
});