Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
650
「 動く」サンプルでスムーズなコミュニケーションを
chigichan24
0
570
Claude CodeでサクサクTestコードを移行しよう
chigichan24
2
760
Live Update notificationのつかいどころ
chigichan24
0
260
不具合調査とTest
chigichan24
1
410
Flutterと難読化
chigichan24
0
5.3k
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
生成AI時代の自動E2Eテスト運用とPlaywright実践知_引持力哉
legalontechnologies
PRO
0
190
21st ACRi Webinar - Univ of Tokyo Presentation Slide (Ayumi Ohno)
nao_sumikawa
0
120
Microsoft Agent 365 を 30 分でなんとなく理解する
skmkzyk
1
490
.NET 10 のパフォーマンス改善
nenonaninu
2
4.9k
直接メモリアクセス
koba789
0
270
Agentic AI Patterns and Anti-Patterns
glaforge
1
170
HIG学習用スライド
yuukiw00w
0
110
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
0
160
Ruby で作る大規模イベントネットワーク構築・運用支援システム TTDB
taketo1113
1
110
AI時代におけるアジャイル開発について
polyscape_inc
0
120
バグハンター視点によるサプライチェーンの脆弱性
scgajge12
2
650
ガバメントクラウド利用システムのライフサイクルについて
techniczna
0
140
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
89
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Unsuck your backbone
ammeep
671
58k
Being A Developer After 40
akosma
91
590k
Context Engineering - Making Every Token Count
addyosmani
9
480
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Practical Orchestrator
shlominoach
190
11k
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を作るには算数⼒が必要