SlideShare a Scribd company logo
thagikura
Deep Dive Into LayoutManager 

for RecyclerView
$ whoami
Takeshi Hagikura
@thagikura


Developer Relations

@Google
RecyclerView
RecyclerView
Adapter
Recycler
LayoutManager
ItemDecoration
ItemAnimator
RecycledViewPool
TouchHelper
DiffUtil



LinearLayoutManager
GridLayoutManager
StaggeredGridLayoutManager
Is it possible to add a
custom LayoutManager?
FlexboxLayoutManager
github.com/google/flexbox-layout
Ports Flexbox in CSS to Android
How to create a
custom LayoutManager?
Think before you build it
Much harder than custom view
Gives you much flexibility
on top of RecyclerView features
At the bare minimum,
need to override…
onLayoutChildren
Called on:
- initial layout
- adapter changes
Lay out all relevant child views
If this isViewGroup
(except RecyclerView)
All child views on memory
In RecyclerView +
LayoutManager
Only visible views should
be on memory
onLayoutChildren
1. Find the anchor position
Anchor position
Starting position to put views.
Start with 0 on initial layout.



Remember the first visible view to
restore the state
onLayoutChildren
1. Find the anchor position
2. Calculate how many items

should be in visible portion
onLayoutChildren
1. Find the anchor position
2. Calculate how many items

should be in visible portion
3. Fill toward end
private int fill(RecyclerView.Recycler recycler,
RecyclerView.State state,
LayoutState layoutState) {
int start = layoutState.mAvailable;
int remainingSpace = layoutState.mAvailable;
int consumed = 0;
while (remainingSpace > 0 &&
layoutState.hasMore(state, mFlexLines)) {
FlexLine flexLine =
mFlexLines.get(layoutState.mFlexLinePosition);
layoutState.mPosition = flexLine.mFirstIndex;
consumed += layoutFlexLine(flexLine, layoutState);
remainingSpace -= flexLine.getCrossSize();
}
layoutState.mAvailable -= consumed;
return start - layoutState.mAvailable;
}
Simplified version of fill
private int fill(RecyclerView.Recycler recycler,
RecyclerView.State state,
LayoutState layoutState) {
int start = layoutState.mAvailable;
int remainingSpace = layoutState.mAvailable;
int consumed = 0;
while (remainingSpace > 0 &&
layoutState.hasMore(state, mFlexLines)) {
FlexLine flexLine =
mFlexLines.get(layoutState.mFlexLinePosition);
layoutState.mPosition = flexLine.mFirstIndex;
consumed += layoutFlexLine(flexLine, layoutState);
remainingSpace -= flexLine.getCrossSize();
}
layoutState.mAvailable -= consumed;
return start - layoutState.mAvailable;
}
mAvailable: Amount of pixels need to be filled
mDirection: START | END
private int fill(RecyclerView.Recycler recycler,
RecyclerView.State state,
LayoutState layoutState) {
int start = layoutState.mAvailable;
int remainingSpace = layoutState.mAvailable;
int consumed = 0;
while (remainingSpace > 0 &&
layoutState.hasMore(state, mFlexLines)) {
FlexLine flexLine =
mFlexLines.get(layoutState.mFlexLinePosition);
layoutState.mPosition = flexLine.mFirstIndex;
consumed += layoutFlexLine(flexLine, layoutState);
remainingSpace -= flexLine.getCrossSize();
}
layoutState.mAvailable -= consumed;
return start - layoutState.mAvailable;
}
Put views and
loop until mAvailable < 0
onLayoutChildren
1. Find the anchor position
2. Calculate how many items

should be in visible portion
3. Fill toward end
4. Fill toward start
Why fill toward both directions?
In some cases anchor position may
be at the bottom
1 2
3
4 5
6 7
8 9
10
11
scrollToPosition(50)
42 43
44
45
46 47
48
49 50
Anchor position
scrollVerticallyBy
Interact with scroll by the user
@Override
public boolean canScrollVertically() {
return true;
}
Could be false depending on attributes.
E.g. Orientation in LinearLayoutManager
@Override
public int scrollVerticallyBy(int dy, 

RecyclerView.Recycler recycler,
RecyclerView.State state) {
if (isMainAxisDirectionHorizontal()) {
int scrolled = 

handleScrollingCrossAxis(dy, recycler, state);
mViewCache.clear();
return scrolled;
} else {
int scrolled = handleScrollingMainAxis(dy);
mAnchorInfo.mPerpendicularCoordinate += scrolled;
mSubOrientationHelper.offsetChildren(-scrolled);
return scrolled;
}
}
@Override
public int scrollVerticallyBy(int dy, 

RecyclerView.Recycler recycler,
RecyclerView.State state) {
if (isMainAxisDirectionHorizontal()) {
int scrolled = 

handleScrollingCrossAxis(dy, recycler, state);
mViewCache.clear();
return scrolled;
} else {
int scrolled = handleScrollingMainAxis(dy);
mAnchorInfo.mPerpendicularCoordinate += scrolled;
mSubOrientationHelper.offsetChildren(-scrolled);
return scrolled;
}
}
Distance to scroll in pixels
@Override
public int scrollVerticallyBy(int dy, 

RecyclerView.Recycler recycler,
RecyclerView.State state) {
if (isMainAxisDirectionHorizontal()) {
int scrolled = 

handleScrollingCrossAxis(dy, recycler, state);
mViewCache.clear();
return scrolled;
} else {
int scrolled = handleScrollingMainAxis(dy);
mAnchorInfo.mPerpendicularCoordinate += scrolled;
mSubOrientationHelper.offsetChildren(-scrolled);
return scrolled;
}
}
The actual distance scrolled
Small dy
Only shift existing views
mRecyclerView.offsetChildrenVertical(dy);
Large dy
Large dy
Recycle views no
longer visible
Large dy
Fill appearing views
What does Recycle mean?
Two types of cache
in RecyclerView
1. Recycle
2. Scrap
Recycler
RecycledViewPool
1. Recycle
Recycler
RecycledViewPool
LayoutManager
recycler.recycleView(View)
1. Recycle
Recycler
RecycledViewPool
LayoutManager
recycler.recycleView(View)
1. Recycle
Considered as dirty
RecyclerRecycler
RecycledViewPool
Can be shared across multiple RecyclerViews
Recycler
Scrap Heap
2. Scrap
Recycler
Scrap Heap
LayoutManager
recycler.scrapView(View)
2. Scrap
Recycler
Scrap Heap
LayoutManager
detachAndScrapAttachedViews
RecyclerView
recycler.scrapView(View)
2. Scrap
How to retrieve aView?
LayoutManager Adapter
Recycler
recycler.getViewForPosition(int)
Case1. Found in scrap
Case2. Found in Recycled Pool
Case3. Not found in cache
LayoutManager Adapter
Recycler
Case1. Found in scrap
LayoutManager Adapter
Recycler
Case2. Found in Recycled Pool
adapter.bindViewHolder
LayoutManager Adapter
Recycler
Case2. Found in Recycled Pool
LayoutManager Adapter
Recycler
Case3. Not found in cache
adapter.createViewHolder
LayoutManager Adapter
Recycler
Case3. Not found in cache
Use scrap if you re-attach in a
same layout pass
Use recycle for views no longer
needed
scrollHorizontallyBy
Same with vertical except for the
direction
Now you implement basic functions.
Is it enough?
Could be useable... but NO.
scrollTo(position)
smoothScrollTo(position)
Fast Scrolling
Item Decorations
Item prefetch
Predictive Animations
There are a lot more…
scrollTo(position)
smoothScrollTo(position)
Fast Scrolling
Item Decorations
Item prefetch
Predictive Animations
There are a lot more…
Predictive Animations
Off OnAdd aView
Off OnDelete aView
@Override
public boolean supportsPredictiveItemAnimations() {
return true;
}
onLayoutChildren
Real Layout
Pre-layout
In pre-layout
Lay out all the views currently visible and
additional views that are appearing (or
disappearing) after the animation
Pre-layout
Remaining
Appearing
Disappearing
To be inserted
at this positionVisible area
Real-layout
Remaining
Appearing
Disappearing
Visible area
Pre-layout
Remaining
Appearing
Disappearing
To be deletedVisible area
Real layout
Remaining
Appearing
Disappearing
Visible area
Now you know the basics of
building a custom LayoutManager
Resources
Source of default LayoutManagers


github.com/google/flexbox-layout


wiresareobsolete.com/2014/09/building-a-recyclerview-
layoutmanager-part-1/

Thank you!
Takeshi Hagikura
@thagikura

More Related Content

What's hot

【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
Unity Technologies Japan K.K.
 

What's hot (20)

レコメンドバッチ高速化に向けたSpark/MapReduceの機械学習ライブラリ比較検証
レコメンドバッチ高速化に向けたSpark/MapReduceの機械学習ライブラリ比較検証レコメンドバッチ高速化に向けたSpark/MapReduceの機械学習ライブラリ比較検証
レコメンドバッチ高速化に向けたSpark/MapReduceの機械学習ライブラリ比較検証
 
這些年,我寫 Angular 時所使用的小技巧
這些年,我寫 Angular 時所使用的小技巧這些年,我寫 Angular 時所使用的小技巧
這些年,我寫 Angular 時所使用的小技巧
 
REST API に疲れたあなたへ贈る GraphQL 入門
REST API に疲れたあなたへ贈る GraphQL 入門REST API に疲れたあなたへ贈る GraphQL 入門
REST API に疲れたあなたへ贈る GraphQL 入門
 
AngularとSpring Bootで作るSPA + RESTful Web Serviceアプリケーション
AngularとSpring Bootで作るSPA + RESTful Web ServiceアプリケーションAngularとSpring Bootで作るSPA + RESTful Web Serviceアプリケーション
AngularとSpring Bootで作るSPA + RESTful Web Serviceアプリケーション
 
大規模スクラムの失敗から学んだこと #AgileJapan2015
大規模スクラムの失敗から学んだこと #AgileJapan2015大規模スクラムの失敗から学んだこと #AgileJapan2015
大規模スクラムの失敗から学んだこと #AgileJapan2015
 
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
 
今さら聞けないDiとspring
今さら聞けないDiとspring今さら聞けないDiとspring
今さら聞けないDiとspring
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門
 
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
 
Confluence と DITA による Webマニュアル作成フロー
Confluence と DITA によるWebマニュアル作成フローConfluence と DITA によるWebマニュアル作成フロー
Confluence と DITA による Webマニュアル作成フロー
 
【Spring fest 2019】徹底解剖Spring MVCアーキテクチャー
【Spring fest 2019】徹底解剖Spring MVCアーキテクチャー【Spring fest 2019】徹底解剖Spring MVCアーキテクチャー
【Spring fest 2019】徹底解剖Spring MVCアーキテクチャー
 
10分でわかるFuelPHP @ 2011/12
10分でわかるFuelPHP @ 2011/1210分でわかるFuelPHP @ 2011/12
10分でわかるFuelPHP @ 2011/12
 
人生がときめくAPIテスト自動化 with Karate
人生がときめくAPIテスト自動化 with Karate人生がときめくAPIテスト自動化 with Karate
人生がときめくAPIテスト自動化 with Karate
 
これで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetup
これで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetupこれで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetup
これで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetup
 
デプロイメントパイプラインって何?
デプロイメントパイプラインって何?デプロイメントパイプラインって何?
デプロイメントパイプラインって何?
 
GroongaでRedmineを高速全文検索
GroongaでRedmineを高速全文検索GroongaでRedmineを高速全文検索
GroongaでRedmineを高速全文検索
 
(2017.6.9) Neo4jの可視化ライブラリまとめ
(2017.6.9) Neo4jの可視化ライブラリまとめ(2017.6.9) Neo4jの可視化ライブラリまとめ
(2017.6.9) Neo4jの可視化ライブラリまとめ
 
最強オブジェクト指向言語 JavaScript 再入門!
最強オブジェクト指向言語 JavaScript 再入門!最強オブジェクト指向言語 JavaScript 再入門!
最強オブジェクト指向言語 JavaScript 再入門!
 
Jakarta CDI 4.0
Jakarta CDI 4.0Jakarta CDI 4.0
Jakarta CDI 4.0
 
Rustに触れて私のPythonはどう変わったか
Rustに触れて私のPythonはどう変わったかRustに触れて私のPythonはどう変わったか
Rustに触れて私のPythonはどう変わったか
 

Similar to Deep Dive Into LayoutManager for RecyclerView

Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficientTh 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Bin Shao
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
Droidcon Berlin
 
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Yuji Hato
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 

Similar to Deep Dive Into LayoutManager for RecyclerView (20)

Mastering RecyclerView Layouts
Mastering RecyclerView LayoutsMastering RecyclerView Layouts
Mastering RecyclerView Layouts
 
Android App Development - 04 Views and layouts
Android App Development - 04 Views and layoutsAndroid App Development - 04 Views and layouts
Android App Development - 04 Views and layouts
 
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficientTh 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
 
How to use redux with react hooks in react native application
How to use redux with react hooks in react native applicationHow to use redux with react hooks in react native application
How to use redux with react hooks in react native application
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
 
Android UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesAndroid UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and Techniques
 
Android UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesAndroid UI Tips, Tricks and Techniques
Android UI Tips, Tricks and Techniques
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice Ninja
 
Recoil at Codete Webinars #3
Recoil at Codete Webinars #3Recoil at Codete Webinars #3
Recoil at Codete Webinars #3
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
React Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのか
 
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
 
Android 3
Android 3Android 3
Android 3
 
Optimize CollectionView Scrolling
Optimize CollectionView ScrollingOptimize CollectionView Scrolling
Optimize CollectionView Scrolling
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Introduction to React Native Workshop
Introduction to React Native WorkshopIntroduction to React Native Workshop
Introduction to React Native Workshop
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - Components
 

Recently uploaded

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
AbrahamGadissa
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 

Recently uploaded (20)

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Scaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageScaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltage
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdfDanfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 

Deep Dive Into LayoutManager for RecyclerView