* RecyclerView 의 구성
    - RecyclerView
    - LayoutManager
    - Adapter
    - ViewHolder : 각각의 Item 을 나타냄


* LayoutManager 종류
    - LinearLayoutManager : 세로 or 가로
    - GridLayoutManager
    - StaggeredGridLayoutManager : 높이가 다른 Item 들을 StaggeredGrid 로 보여줄 때


* smoothScrollToPosition() 이 동작하지 않을 때
    - Layout 이 완료된 후에 scroll 해야 정상 동작
    - 아래와 같이 GlobalLayoutListener 통해 Scroll 처리 or scrollToPosition() 으로 대체

recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
recyclerView.smoothScrollToPosition(position);
recyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});

    

'SW > Android' 카테고리의 다른 글

ANR (Application Not Responding)  (0) 2020.08.15
//View  (0) 2020.06.20
AsyncQueryHandler 와 Loader  (0) 2019.09.08
Asynchronization Task  (0) 2019.09.08
IPC (Inter Process Communication)  (0) 2019.09.07

+ Recent posts