Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
Search
Keishin Yokomaku
November 10, 2023
Technology
770
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
Keishin Yokomaku
November 10, 2023
More Decks by Keishin Yokomaku
See All by Keishin Yokomaku
Base64 in Android
keithyokoma
0
66
One screen, many BottomSheets
keithyokoma
0
490
Build apps for Cars
keithyokoma
0
610
Save the state
keithyokoma
0
650
Either in Kotlin
keithyokoma
0
660
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
5.7k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
5.4k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
590
DX Improvements
keithyokoma
3
470
Other Decks in Technology
See All in Technology
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
120
Deep Data Security 機能解説
oracle4engineer
PRO
2
710
営業オントロジーの作り方と、エージェントからの辿り方 ── ナレッジワークの現場から
kworkdev
PRO
1
270
組み立てて楽しむ AWS Blocks 入門
kmiya84377
0
220
[2026 Oracle Technical Deep Dive] OCI AI Resilience -OCIのセキュリティ対策機能をきちんと使いこなす- (2026年9月17日開催)
oracle4engineer
PRO
0
130
The seven pitfalls of AI (revised version)
ufried
0
270
今こそ知りたいAmplifyGen2
mkdev10
2
150
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
330
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
590
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
『GOエコノミー 』(相乗りサービス) におけるスペック駆動開発
mot_techtalk
1
310
[2026 Oracle Technical Deep Dive] AI時代のアプリケーションを支えるCloud NativeとJava EEモダナイゼーション (2026年9月17日開催)
oracle4engineer
PRO
0
120
Featured
See All Featured
Odyssey Design
rkendrick25
PRO
2
860
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Claude Code のすすめ
schroneko
67
230k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
4 Signs Your Business is Dying
shpigford
187
23k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
500
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
860
The Language of Interfaces
destraynor
162
27k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
550
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
Music & Morning Musume
bryan
48
7.4k
Transcript
LazyColumnͷitem͕ViewPortͷ தͰΊΔྖҬͷׂ߹ΛΓ͍ͨ Keishin Yokomaku (@KeithYokoma) / Giftmall, inc. Shibuya.apk #45
Γ͍ͨʂ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ Γ͍ͨ͜ͱ 100% n% m% 0% Shibuya.apk #45
Γ͍ͨʂ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ LazyListState ͰܭࢉͰ͖Δ ▸ ViewPort ͷେ͖͞ ▸ LazyListState.layoutInfo.viewportSize Ͱऔಘ͢Δ ▸
ViewPort ʹऩ·͍ͬͯΔ item ͷߴ͞ ▸ LazyListItemInfo ͱ LazyListState.layoutInfo ΛΈ߹ΘͤΔ ▸ LazyListItemInfo ͷϦετ ViewPort ʹ͋Δͷ͔͠ೖ͍ͬͯͳ͍ ▸ item ͕ը໘֎ʹ͋Δͱ͖ܭࢉ͠ͳͯ͘0%ͱ͔Δ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ViewPort ʹऩ·͍ͬͯΔ item ͷߴ͞ ▸ ViewPort ʹऩ·͍ͬͯΔߴ͞ = ViewPort
ʹ͋Δ item ͷԼͷ࠲ඪ - ্ͷ࠲ඪ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ViewPort ʹऩ·͍ͬͯΔ item ͷߴ͞ ্ Լ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ViewPort ʹऩ·͍ͬͯΔ item ͷߴ͞ ▸ ্ ▸ ViewPort ͦͷͷͷ
offset ͱ item ͷ offset Ͱ্Λܭࢉ ▸ offset ෛͷʹͳΓಘΔ͕ɺܭࢉ݁ՌෛʹͳΒͳ͍Α͏ʹௐ ▸ Լ ▸ ViewPort ͦͷͷͷ offset ͱɺitem શମͷ offset ͱߴ͞ͰԼΛܭࢉ ▸ ͪ͜Β offset ෛͷʹͳΓಘΔ ▸ item ͕ ViewPort ΑΓେ͖͍߹ɺ࠷େͷߴ͞ ViewPort ͷେ͖͞ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ViewPort ʹऩ·͍ͬͯΔ item ͷߴ͞ fun LazyListState.visibleHeight(itemInfo: LazyListItemInfo): Int {
val start = (layoutInfo.viewportStartOffset + itemInfo.offset) .coerceAtLeast(0) val end = (itemInfo.offset + itemInfo.size - layoutInfo.viewportEndOffset) .coerceAtLeast(itemInfo.offset + itemInfo.size) .coerceAtMost(layoutInfo.viewportSize.height) return end - start } Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ViewPort ʹΊΔ item ͷߴ͞ͷׂ߹ fun LazyListState.calculateOccupationInViewport(position: Int): Float =
calculateOccupationInViewport(listOf(position)) fun LazyListState.calculateOccupationInViewport(positions: List<Int>): Float { val viewportSize = layoutInfo.viewportSize val totalTargetHeight = layoutInfo.visibleItemsInfo .filter { info -> positions.contains(info.index) } .sumOf { info -> visibleHeight(info) } return totalTargetHeight.toFloat() / viewportSize.height } Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ҙ: stickyHeader Λ͏࣌ ▸ ׂ߹͕1.0fΛ͑Δ͜ͱ͕͋Δ ▸ ࣍ͷ݅Λຬͨ࣌͢ ▸ ෳͷ
item ͷߴ͞Ͱׂ߹Λܭࢉ͢Δ ▸ ViewPort ΑΓେ͖͍ item ͕ܭࢉʹ͍Δ ▸ item ʹॏͳ͍ͬͯΔ stickyHeader ܭࢉʹೖΔͱ͖ ▸ stickyHeader item ʹॏͶͯද͍ࣔͯ͠ΔͷͰɺ ॏͳΓͷ෦Λݮࢉ͠ͳ͍ͱ1.0fΛ͑ͯ͠·͏ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ҙ: stickyHeader Λ͏࣌ LazyListItemInfo.index: 0 LazyListItemInfo.index: 1 LazyListItemInfo.index: 2
… Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ҙ: stickyHeader Λ͏࣌ ▸ LazyListItemInfo.index ͷ ▸ stickyHeader
item ͯ͢·ͱΊͯ௨͠൪߸ʹͳΔ ▸ stickyHeader ΛܭࢉʹೖΕͨ͘ͳ͍ͱ͖ ▸ stickyHeader ͱ͔Δ key Λઃఆ͢Δ ▸ ࣗͰ stickyHeader ͕Կ൪ʹདྷΔ͔͓֮͑ͯ͘ Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ ҙ: LazyListState ͷߋ৽ස ▸ LazyListState ͍͍͢͝Ͱߋ৽͞ΕΔ ▸ ࣍ͷ͍ͣΕ͔Ͱϥοϓͯ͠దͳසͰܭࢉ͢Δ ▸
derivedStateOf ▸ LaunchedEffect + snapshotFlow Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷதͰΊΔྖҬͷׂ߹ΛΓ͍ͨ About me ▸ Keishin Yokomaku - @KeithYokoma ▸ GitHub
/ Twitter / Stack Over fl ow ▸ Giftmall, Inc. / Android App Engineer Shibuya.apk #45
LazyColumnͷitem͕ViewPortͷ தͰΊΔྖҬͷఔΛΓ͍ͨ Keishin Yokomaku (@KeithYokoma) / Giftmall, inc. Shibuya.apk #45