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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
830
「 動く」サンプルでスムーズなコミュニケーションを
chigichan24
1
730
Claude CodeでサクサクTestコードを移行しよう
chigichan24
2
950
Live Update notificationのつかいどころ
chigichan24
0
270
不具合調査とTest
chigichan24
1
420
Flutterと難読化
chigichan24
0
5.4k
Building Android and looking into the Android System
chigichan24
2
4.2k
DroidKaigiカンファレンスアプリの歴史からみるアプリアーキテクチャのこれまでとこれから
chigichan24
2
3.5k
継続的に機能開発を進めながら行うマルチモジュール化
chigichan24
2
6.1k
Other Decks in Technology
See All in Technology
JuliaTokaiとしてはこれが最後かもしれない(仮) for NGK2026S
antimon2
0
130
Zephyr RTOS の発表をOpen Source Summit Japan 2025で行った件
iotengineer22
0
290
toCプロダクトにおけるAI機能開発のしくじりと学び / ai-product-failures-and-learnings
rince
6
4.4k
「全社導入」は結果。1人の熱狂が組織に伝播したmikanのn8n活用
sota_mikami
0
580
ファシリテーション勉強中 その場に何が求められるかを考えるようになるまで / 20260123 Naoki Takahashi
shift_evolve
PRO
3
400
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
41k
ドキュメントからはじめる未来のソフトウェア
pkshadeck
4
2k
The Engineer with a Three-Year Cycle - 2
e99h2121
0
200
【インシデント入門】サイバー攻撃を受けた現場って何してるの?
shumei_ito
0
1.1k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
2人で作ったAIダッシュボードが、開発組織の次の一手を照らした話― Cursor × SpecKit × 可視化の実践 ― Qiita AI Summit
noalisaai
0
260
AI時代にあわせたQA組織戦略
masamiyajiri
6
2.9k
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
630
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
160
Building Applications with DynamoDB
mza
96
6.9k
KATA
mclloyd
PRO
34
15k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
HDC tutorial
michielstock
1
330
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Speed Design
sergeychernyshev
33
1.5k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
750
GraphQLとの向き合い方2022年版
quramy
50
14k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
900
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を作るには算数⼒が必要