LinearLayoutManager setReverseLayout() == true 但 items 从底部堆叠
2022-08-31 22:39:46
这似乎是一个简单的解决方案,但似乎设置
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private LinearLayoutManager mLayoutManager;
.... // More code
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
// Add item decoration
mRecyclerView.addItemDecoration(new SpacesItemDecoration(DIVIDER_SPACE));
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new LinearLayoutManager(getActivity());
mLayoutManager.setReverseLayout(true); // THIS ALSO SETS setStackFromBottom to true
mRecyclerView.setLayoutManager(mLayoutManager);
似乎还将项目设置为从底部堆叠
我试图设置为false,但这没有做任何事情,什么是颠倒项目顺序但仍然从顶部填充的最佳方法?我应该改用自定义比较器类吗?我希望这比创建另一个类更容易。setStackFromBottom