Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Battle of GridLayout with RecyclerView
Search
Kazuki Chigita
March 26, 2019
Technology
0
290
Battle of GridLayout with RecyclerView
GridLayout with RecyclerView
Kazuki Chigita
March 26, 2019
Tweet
Share
More Decks by Kazuki Chigita
See All by Kazuki Chigita
不具合調査とTest
chigichan24
1
280
Flutterと難読化
chigichan24
0
4.2k
Building Android and looking into the Android System
chigichan24
2
4k
DroidKaigiカンファレンスアプリの歴史からみるアプリアーキテクチャのこれまでとこれから
chigichan24
3
3.3k
継続的に機能開発を進めながら行うマルチモジュール化
chigichan24
2
5.8k
Application Design 勉強会 #12
chigichan24
0
61
Application Design 勉強会 #10
chigichan24
0
84
Application Design 勉強会 #6
chigichan24
0
170
Application Design 勉強会 #4
chigichan24
0
160
Other Decks in Technology
See All in Technology
論文紹介 ”Long-Context LLMs Meet RAG: Overcoming Challenges for Long Inputs in RAG” @GDG Tokyo
shukob
0
270
サーバーレスで楽しよう!お気軽に始められる3つのポイント / Have fun with Serverless!
_kensh
2
230
SREとしてスタッフエンジニアを目指す / SRE Kaigi 2025
tjun
15
6.4k
Redshiftを中心としたAWSでのデータ基盤
mashiike
0
100
Fin-JAWS第38回reInvent2024_全金融系セッションをライトにまとめてみた
mhrtech
1
100
Platform EngineeringがあればSREはいらない!? 新時代のSREに求められる役割とは
mshibuya
2
4k
[SRE kaigi 2025] ガバメントクラウドに向けた開発と変化するSRE組織のあり方 / Development for Government Cloud and the Evolving Role of SRE Teams
kazeburo
4
1.9k
企業テックブログにおける執筆ネタの考え方・見つけ方・広げ方 / How to Think of, Find, and Expand Writing Topics for Corporate Tech Blogs
honyanya
0
810
Amazon Location Serviceを使ってラーメンマップを作る
ryder472
2
160
20250129 Findy_テスト高活用化
dshirae
0
230
パブリッククラウドのプロダクトマネジメントとアーキテクト
tagomoris
4
770
攻撃者の視点で社内リソースはどう見えるのかを ASMで実現する
hikaruegashira
4
2.1k
Featured
See All Featured
Practical Orchestrator
shlominoach
186
10k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
A better future with KSS
kneath
238
17k
How to train your dragon (web standard)
notwaldorf
89
5.8k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Code Review Best Practice
trishagee
65
17k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
380
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Embracing the Ebb and Flow
colly
84
4.5k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
520
Transcript
Battle of GridLayout with RecyclerView chigichan24 @ CA.apk #7 5
min
$whoami Kazuki Chigita (chigichan24) AbemaTV でインターン中 takahiromさんのもとAndroid開発のいろはを学んでいる
GridLayout
GridLayout جૅ
pulic class GridLayout extends ViewGroup جૅ
pulic class GridLayout extends ViewGroup N+1本の線でN個の等分領域に分けられる جૅ
pulic class GridLayout extends ViewGroup 0 1 2 … ⼦Viewはなんの指定もしなければ
各領域に広がる N+1本の線でN個の等分領域に分けられる جૅ
pulic class GridLayout extends ViewGroup 0 1 2 N+1本の線でN個の等分領域に分けられる ⼦Viewに専有したい数を渡せば
その分だけ広がる GridLayoutManager.SpanSizeLookUp()を使う جૅ
GridLayout
GridLayout with RecyclerView
How to adapt?
How to adapt? binding.recyclerView.layoutManager = GridLayoutManager(context, spanCount)
How to adapt? binding.recyclerView.layoutManager = GridLayoutManager(context, spanCount)
How to adapt? binding.recyclerView.layoutManager = GridLayoutManager(context, spanCount) N+1本の線でN個の等分領域に分けられる
Battle of GridLayout with RecyclerView chigichan24 @ CA.apk #7 5
min
Battle of GridLayout with RecyclerView chigichan24 @ CA.apk #7 5
min
GridLayout (span)
GridLayout (span) ͱ
GridLayout (span) RecyclerView (Itemdecoration) ͱ
GridLayout (span) RecyclerView (Itemdecoration) ͱ ͍ΖΜͳLayout͕ΊΔ
͜ΜͳLayoutΛ͘Έ͍ͨ1
͜ΜͳLayoutΛ͘Έ͍ͨ1
͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする
͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {
//positionに応じて割り当てるサイズを渡す. } }
͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {
//positionに応じて割り当てるサイズを渡す. return when { position == 0 -> 4 position <= 2 -> 2 else -> 1 } } }
͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {
//positionに応じて割り当てるサイズを渡す. return when { position == 0 -> 4 position <= 2 -> 2 else -> 1 } } } RecyclerViewのItemDecorationのうちgetItemOffestsをoverride
͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {
//positionに応じて割り当てるサイズを渡す. return when { position == 0 -> 4 position <= 2 -> 2 else -> 1 } } } RecyclerView. ItemDecoration() { override fun getItemOffests( outRect: Rect, view: View, parent: RecyclerView, state: RecylerView.State ) { outRect.left = margin ... } }
͜ΜͳLayoutΛ͘Έ͍ͨ2
͜ΜͳLayoutΛ͘Έ͍ͨ2 SpanCountは何分割にすればよいのか?
͜ΜͳLayoutΛ͘Έ͍ͨ2 SpanCountは何分割にすればよいのか? 等幅 & センタリング にしないといけない
͜ΜͳLayoutΛ͘Έ͍ͨ2 SpanCountは何分割にすればよいのか? 等幅 & センタリング にしないといけない 8
͜ΜͳLayoutΛ͘Έ͍ͨ2
͜ΜͳLayoutΛ͘Έ͍ͨ2
͜ΜͳLayoutΛ͘Έ͍ͨ2 SpaceItemを導⼊する
͜ΜͳLayoutΛ͘Έ͍ͨ2 SpaceItemを導⼊する (複数のItemが必要になってくるとGroupieが便利です)
ҰൠԽ ここに⼊るViewの数は 可変にしたい
ҰൠԽ 最⼤幅になりうる数の集合の最⼩公倍数×2 (多分) ここに⼊るViewの数は 可変にしたい
·ͱΊ GridLayoutとRecyclerViewはいろいろできる いい感じのLayoutを作るには算数⼒が必要