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
67
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
しろおびから始める!ログ活用の第一歩
shumei_ito
0
880
今さら理解するウェブフォントver.2026
takanorip
3
660
AI 時代の Azure エンジニアリング ~ 私たちは何を磨き、何を任せるのか ~
chack411
1
580
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
0
190
継続的なAIコスト最適化
bgpat
1
280
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
360
自主式軟體工廠
philipz
0
250
今こそ知りたいAmplifyGen2
mkdev10
2
160
契約書画像からの情報抽出に特化した視覚接地モデルを育てる話
sansantech
PRO
1
160
Loop Engineering これくらいでいい
mikanichinose
0
210
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
4
1.2k
LocalStack を使ったサーバーレスアプリケーション開発 / Serverless Development with LocalStack
kakakakakku
1
390
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
620
Deep Space Network (abreviated)
tonyrice
0
360
Designing Powerful Visuals for Engaging Learning
tmiket
1
600
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
A better future with KSS
kneath
240
18k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
560
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Thoughts on Productivity
jonyablonski
76
5.4k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Curse of the Amulet
leimatthew05
3
15k
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