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
780
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
74
One screen, many BottomSheets
keithyokoma
0
500
Build apps for Cars
keithyokoma
0
610
Save the state
keithyokoma
0
660
Either in Kotlin
keithyokoma
0
670
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
5.7k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
5.4k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
600
DX Improvements
keithyokoma
3
480
Other Decks in Technology
See All in Technology
AI時代の組織作り:チーム開発から「個人×AI」への移行と、持続可能な「開発資本」の築き方
ham0215
2
310
令和の今、あらためて IAM を考える。アクセスキーを「無くせない現実」との向き合い方
kazzpapa3
0
460
複雑な業務システムを高速でつくるため、チーム全員をつくれる人へ
ayakurabuchi
0
140
PostgreSQL オプティマイザ統計の秘密
nori_shinoda
0
390
DBTS2026 盛り上がってますか!?Databricksが実現するAI時代のデータ基盤
akuwano
1
190
業務でAWSをあまり使っていない私が、AWSへのモチベを保つ方法
smt7174
0
180
Sinatra on PicoRuby ローカルでセルフホスト
bash0c7
0
110
cdkd (CDK Direct)
gotok365
4
270
試験勉強はGrokBotでやれ
maigo999
0
110
Technical Project Manager の役割とやりがい、少しだけ AI
yoshiiryo1
0
600
分析作業をどこまで任せるか自分で決められる AIネイティブBI『Golden Analytics』が 良さげな話 /golden-analytics-is-ai-native-bi
shinyaa31
0
130
少ない人手 限られた予算 それでも守る 消せない・見つける・戻れる オールハザード型BCP on AWS / 20261107 Mitsutoshi Matsuo
shift_evolve
PRO
0
230
Featured
See All Featured
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
470
Rails Girls Zürich Keynote
gr2m
96
14k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
350
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
970
How to Talk to Developers About Accessibility
jct
2
610
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
530
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
650
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Chasing Engaging Ingredients in Design
codingconduct
0
390
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