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
71
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
670
持続的なアプリ開発のための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
GitHub、使う?使わない?
happysamurai294
0
110
LLMの知識とAIエージェント
happysamurai294
0
110
reInvent2026stby LT00 "Change your life!"
shinichirokawano
1
410
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
250
DevelopersIO 2026 Tokyo 現時点の衛星通信サービスの現状を整理してみる
maroon1st
0
320
[FECONF-2026] 신대륙을 향한 카카오페이증권 프론트엔드 항해기 (이주승)
l1ghthouse
0
250
デザインレビューは自動化できるのか?─ Flutter × Figma で UI 品質保証を考える
techiro
2
390
あなたのDartコードは丸見えかもしれない ~reFlutterで暴くFlutterアプリの中身と多層防御~
zozotech
PRO
0
530
仕様駆動開発の、その先へ。決める力と確かめる仕組み
inariku
0
110
契約で守るコンパウンドプロダクトのデザインシステム
yug1224
1
1.6k
バイブコーディングの特徴と「コケて直す」ループ
happysamurai294
0
110
Microsoft のサポート ライフサイクルを理解する
murachiakira
PRO
0
220
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Designing for Timeless Needs
cassininazir
1
530
Practical Orchestrator
shlominoach
192
12k
Utilizing Notion as your number one productivity tool
mfonobong
4
630
Test your architecture with Archunit
thirion
2
2.5k
Designing Experiences People Love
moore
143
24k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Technical Leadership for Architectural Decision Making
baasie
3
620
The Cult of Friendly URLs
andyhume
79
7k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Done Done
chrislema
187
17k
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