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
310
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
あの日のHotReloadはなぜ動かなかったのか? 〜OSセキュリティ(W^X)とJITコンパイラの攻防〜
chigichan24
3
770
「 動く」サンプルでスムーズなコミュニケーションを
chigichan24
1
660
Claude CodeでサクサクTestコードを移行しよう
chigichan24
2
870
Live Update notificationのつかいどころ
chigichan24
0
260
不具合調査とTest
chigichan24
1
420
Flutterと難読化
chigichan24
0
5.4k
Building Android and looking into the Android System
chigichan24
2
4.1k
DroidKaigiカンファレンスアプリの歴史からみるアプリアーキテクチャのこれまでとこれから
chigichan24
2
3.4k
継続的に機能開発を進めながら行うマルチモジュール化
chigichan24
2
6.1k
Other Decks in Technology
See All in Technology
技術選定、下から見るか?横から見るか?
masakiokuda
0
170
[2025-12-12]あの日僕が見た胡蝶の夢 〜人の夢は終わらねェ AIによるパフォーマンスチューニングのすゝめ〜
tosite
0
240
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
210
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
AWS Lambda durable functions を使って AWS Lambda の15分の壁を超えてみよう
matsuzawatakeshi
0
120
Oracle Cloud Infrastructure:2025年12月度サービス・アップデート
oracle4engineer
PRO
0
170
Bedrock AgentCore Evaluationsで学ぶLLM as a judge入門
shichijoyuhi
2
310
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
570
[PR] はじめてのデジタルアイデンティティという本を書きました
ritou
0
710
Agent Skillsがハーネスの垣根を超える日
gotalab555
7
5.1k
さくらのクラウド開発ふりかえり2025
kazeburo
2
1.3k
DATA SUMMIT 2025 生成 AI 時代におけるデータ分析基盤の在り方:オンプレミスからのクラウド移行とモダンデータスタックの実現
coldairflow
0
110
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Code Reviewing Like a Champion
maltzj
527
40k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
140
Measuring & Analyzing Core Web Vitals
bluesmoon
9
720
Become a Pro
speakerdeck
PRO
31
5.8k
What's in a price? How to price your products and services
michaelherold
246
13k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
100
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Exploring anti-patterns in Rails
aemeredith
2
220
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
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を作るには算数⼒が必要