我希望实现Button,以在水平和垂直布局之间切换“回收”视图。 如果Recycleview最初位于“垂直位置”,则在单击按钮时更改为“水平”,反之亦然。
我的逻辑是
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//If Recycleview is in Horizontal then
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
//If Recycleview is in Vertical then
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
}
谢谢。