在开发时,数组返回数目很少,需求要求不能左右滑动;
解决方法:
-
RecyclerView 为垂直状态(VERTICAL)下:
LinearLayoutManager layoutManager = new LinearLayoutManager(context){ @Override public boolean canScrollVertically() { return false; } }; recyclerView.setLayoutManager(layoutManager);
-
RecyclerView 为水平状态(HORIZONTAL)下:
LinearLayoutManager layoutManager = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false){ @Override public boolean canScrollHorizontally() { return false; } }; recyclerView.setLayoutManager(layoutManager);
网友评论