RecycleView的layoutManager.setStackFromEnd(true);layoutManager.setReverseLayout(true);

1.使用

RecycleView中item從上到下依次添加,並且第一個添加的item始終在最上面,新添加的item需要滑下去才能看到。

layoutManager =new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)

這裏寫圖片描述

2.使用

layoutManager =new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL,true);

RecycleView中item從下到上依次添加,並且第一個添加的item始終在最下面,新添加的item需要滑上去才能看到。 

這裏寫圖片描述

3.使用

layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
layoutManager.setStackFromEnd(true);

這樣子的話,先添加的item會被頂上去,最新添加的item每次都會顯示在最下面 

這裏寫圖片描述

4.使用

layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
layoutManager.setStackFromEnd(true);

“`
這樣設置新添加的始終在頂部,之前添加的會被擠下去

這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章