How to save scroll position of RecyclerView in Android?

后端 未结 8 1386
耶瑟儿~
耶瑟儿~ 2020-11-27 06:20

I have Recycler view which lays inside of SwipeRefreshLayout. Also, have ability to open each item in another activity. After returning back to Recycler I need scroll to cho

8条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 06:43

    The easiest and transition compatible way I found is:

       @Override
    public void onPause() {
        super.onPause();
        recyclerView.setLayoutFrozen(true);
    }
    
    @Override
    public void onResume() {
        super.onResume();
        recyclerView.setLayoutFrozen(false);
    }
    

提交回复
热议问题