我想删除RecyclerView项目之间的分隔符(空格)
因此,尝试设置background
项目视图和RecyclerView
到White
,但它不工作怎么解决?
物品查看XML
:
活动XML:
Activity
课程:
rv_categories.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); rv_categories.setItemAnimator(new DefaultItemAnimator());
首先定义您的RecyclerView:
RecyclerView recycle =(RecyclerView)findViewById(R.id.recyclerView);
并在您的活动中使用此方法:
recycle.addItemDecoration(new DividerItemDecoration(context, 0));
您可以使用DividerItemDecoration
类并覆盖其onDraw
方法,不执行任何操作:
mRecyclerView.addItemDecoration(new DividerItemDecoration(mContext, LinearLayoutManager.VERTICAL) { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { // Do not draw the divider } });