我在Android项目中创建recyclerView
,我想在gridLayout manager
中设置recyclerView
。
这是我的代码:
workHourRecycler = view.findViewById(R.id.market_hours_recycler);
workHourRecycler.setLayoutManager(new GridLayoutManager(getContext(),4));
但是GridLayout
必须'rtl direction'
有人有想法吗?
感谢。
答案 0 :(得分:1)
您需要以编程方式更改RecycleView
workHourRecycler = view.findViewById(R.id.market_hours_recycler);
workHourRecycler.setLayoutManager(new GridLayoutManager(getContext(),4));
//Programtically set the direction
workHourRecycler.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
答案 1 :(得分:0)
试试这个
GridLayoutManager layoutManager = new GridLayoutManager(this, numberOfRows, GridLayoutManager.HORIZONTAL, true);
答案 2 :(得分:0)
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2);
rvProductlist.setLayoutManager(mLayoutManager);
答案 3 :(得分:0)
/**
* @param context Current context, will be used to access resources.
* @param spanCount The number of columns or rows in the grid
* @param orientation Layout orientation. Should be {@link #HORIZONTAL} or {@link
* #VERTICAL}.
* @param reverseLayout When set to true, layouts from end to start.
*/
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 4, GridLayoutManager.HORIZONTAL, true);
rv_days.setLayoutManager(mLayoutManager);
rv_days.setItemAnimator(new DefaultItemAnimator());