Android-RecyclerView禁止滑动

新一
2022-08-04 / 0 评论 / 311 阅读 / 正在检测是否收录...

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);

RecyclerView 为网格状态下:

                GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(),7){
                            @Override
                            public boolean canScrollVertically() {
                                return false;
                            }
                        };
                 recyclerView.setLayoutManager(gridLayoutManager);

l6es2pay.png

本文共 22 个字数,平均阅读时长 ≈ 1分钟
2

打赏

:D 获取中...

更多精彩文章,按Ctrl+D收藏本站!

评论 (0)

取消