RecyclerView decorator adding extra padding on refresh

后端 未结 8 2345
轻奢々
轻奢々 2021-02-01 17:42

So, I\'m facing a weird problem while implementing RecyclerView in my project. I have a custom decorator to implement a consistent top and bottom padding and a rather different

8条回答
  •  感动是毒
    2021-02-01 17:58

    I face the same issue. Fix it with if check

        if (recyclerView.getItemDecorationAt(0) == null) { // check decoration here
            FlexboxItemDecoration agentDividerItemDecoration = new FlexboxItemDecoration(rv.getContext());
            agentDividerItemDecoration.setDrawable(recyclerView.getContext().getResources().getDrawable(R.drawable.shape_divider_flex_normal));
            recyclerView.addItemDecoration(agentDividerItemDecoration);
        } else {
            Log.i(TAG, "initTagsView: ItemDecoration not null");
        }
    

提交回复
热议问题