recyclerview簡單實現橫向滑動
阿新 • • 發佈:2021-01-06
技術標籤:安卓
網格佈局
GridLayoutManager manager = new GridLayoutManager(getActivity(),5);//數字為行數或列數
manager.setAutoMeasureEnabled(true);
manager.setOrientation(LinearLayoutManager.HORIZONTAL);//設定為橫向滑動
recyclerView.setLayoutManager(manager);
線性佈局1
LinearLayoutManager layoutManager = new LinearLayoutManager (getContext());
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);//設定為橫向滑動
recyclerView.setLayoutManager(layoutManager);
線性佈局2
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL,false));