RecyclerView实现列表倒序排列

RecyclerView的布局是有LayoutManager控制的,LinearLayoutManager就支持了倒序的功能

  1. setStackFromEnd(true)
  2. setReverseLayout(true)
  3. list.addFirst(item) 在数据上,可以考虑使用上面3的方法,直接添加数据到列表的头部,或者重写adapter的getItem方法,改为get(size-1-position)

RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

LinearLayoutManager layout = new LinearLayoutManager(this);
layout.setStackFromEnd(true);//列表再底部开始展示,反转后由上面开始展示
layout.setReverseLayout(true);//列表翻转
rv.setLayoutManager(layout);

final SimpleRvAdapter adapter = new SimpleRvAdapter(this);
rv.setAdapter(adapter);

你可能感兴趣的:(RecyclerView实现列表倒序排列)