Set drawable for DividerItemDecoration

后端 未结 4 1369
感动是毒
感动是毒 2021-02-02 05:28

I\'m trying to set my custom drawable (line) for DividerItemDecoration, but with no success. Where is the mistake?

DividerItemDecoration dividerItemDecoration =          


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 06:29

    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(),
                    LinearLayoutManager.HORIZONTAL);
    dividerItemDecoration.setDrawable(getContext().getResources().getDrawable(R.drawable.line_decoration));
            recyclerView.addItemDecoration(dividerItemDecoration);
            DividerItemDecoration dividerItemDecorationVertical = new DividerItemDecoration(getContext(),
                    LinearLayoutManager.VERTICAL);
    
            dividerItemDecorationVertical.setDrawable(getContext().getResources().getDrawable(R.drawable.line_decoration));
            recyclerView.addItemDecoration(dividerItemDecorationVertical);
    

提交回复
热议问题