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
ScrollViewで 読了計測した話
Search
ogapants
December 11, 2018
Technology
880
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ScrollViewで 読了計測した話
2018/12/11 Otemachi.apk
ogapants
December 11, 2018
More Decks by ogapants
See All by ogapants
5分でわかるWebView+ViewGroupを実現するAOSPメールアプリの内部実装と ニュースアプリへの応用 / Otemachi.apk02
ogapants
0
790
WebView+ViewGroupを実現するAOSPメールアプリの内部実装とニュースアプリへの応用 / DroidKaigi2019
ogapants
3
3.9k
「AndroidはiOSと同じデザインで!」と言われたときのTips
ogapants
17
8.5k
たのしいAndroidかいはつ
ogapants
0
200
Fabric Digitsで始めるSMS認証
ogapants
1
1.3k
MediaController をカスタマイズするぞ
ogapants
0
2.8k
Other Decks in Technology
See All in Technology
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
4
300
SREへの勘違いに気づいた後の話
tomodakengo
0
110
AI に書かせたその API、 “信頼” できますか?
nagix
0
120
「守り」で活用するオンデバイスLLM 〜写ってはいけないを総力戦で防ぐ〜 / iOSDC Japan 2026
nakamuuu
0
170
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
170
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
520
リアーキテクチャ後の障害ゼロを目指したShadow Testingの取り組み
nihonbuson
PRO
1
150
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
9
1k
Issue 駆動でスペシャリストの意図を届ける、AI 実装のアクセシビリティ向上
thkt
0
120
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
2.1k
データ_AIの事業の勝敗をわけるもの
nek0128
1
450
ソフトウェアDNAとクラウドエージェントのススメ
cloudace
0
110
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
810
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
A better future with KSS
kneath
240
18k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Rails Girls Zürich Keynote
gr2m
96
14k
Navigating Weather and Climate Data
rabernat
0
520
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Transcript
ScrollViewͰ ಡྃܭଌͨ͠ 2018/12/11 Otemachi.apk @ogapants
ࣗݾհ • ͓͕ͺΜ@ogapants • ೖࣾ • ٕज़ॻయͰνʔϜվળͱ AndroidStudioͷTipsʹ͍ͭͯॻ͍ͨ noteͰങ͑ΔΑʂ https://goo.gl/AWv7v1
ScrollViewͰ ಡྃܭଌͨ͠
ʮಡྃʯͱ • શͯಡΈऴ͑Δ͜ͱ • ΞϓϦͰ͍͏ͱը໘ͷҙͷॴ·ͰεΫ ϩʔϧ͠ऴΘΔ͜ͱ
ฐࣾʹ͓͚Δಡྃܭଌͱ • ୭͕ • ͲͷهࣄΛ • Ͳ͔͜Β • Ͳ͜·Ͱ •
ͲΕ͘Β͍ͷ࣌ؒͰ • ಡΜ͔ͩʢεΫϩʔϧ͔ͨ͠ʣ Λܭଌͯ͠αʔόʔʹૹΓɺσʔλνʔϜ͕ੳ
ಡྃܭଌͱ • ༨ஊɿૹΓઌࣾͷܭଌج൫ʮAtlasʯ
ԿΛͨ͠ͷ͔
ͳͥͨ͠ͷ͔ • ϢʔβʔʹΑΓଟ͘هࣄΛಡΜͰ΄͍͠ ˠBը໘Λ࡞Γ͍ͨ ˠطଘͷAը໘ͱൺͯͲ͏͔ςετ͍ͨ͠ ˠPV͚ͩͩͱਅ৽͠͞ͰݟΒΕ͍ͯΔՄೳੑ ˠܧଓతʹڵຯΛ࣋ͬͯಡΜͰ͍Δ͔Γ͍ͨ ˠΑΓϢʔβʔͷߦಈΛৄ͘͠ܭଌ͢Δඞཁ͕ ͋Δ
ԿΛͨ͠ͷ͔ • Aը໘ͱBը໘Ͱಡྃʹ͕ࠩແ͍͔ܭଌ Aը໘ Bը໘
Ͳ͏ͩͬͨͷ͔ • ݁ՌɺBը໘ظҎ্ͷಡ͕ྃ͞Εͨ • Bը໘ͷ༗༻ੑΛࣈతࠜڌΛ ࣋ͬͯΞϐʔϧͰ͖ͨ • ۙϦϦʔε༧ఆʂ
ΞϓϦهࣄը໘ͷߏ
هࣄը໘ͷߏ ϔομʔ ʢλΠτϧͳͲʣ ίϯςϯπ (WebView) ϑολʔ ʢؔ࿈هࣄҰཡͳͲʣ ʢಡྃʹؚ·ͳ͍ʣ ScrollView Ad
هࣄը໘ͷߏ device ViewPagerͰ εϫΠϓՄೳ
ܭଌ͢Δͷ
ܭଌ͢Δͷ • ૹΔ • ૹΔλΠϛϯά
ૹΔ • هࣄ͕ඇදࣔʹͳΔ·Ͱͷ࣌ؒ(ms)ɹˠ؆୯ͳλΠϚʔΫϥεΛ ࡞ͬͨ • هࣄશମͷ͞(px)ɹˠಡྃͷॏ͞ΛΔͨΊ • هࣄදࣔ࣌ͷઌ಄(px)ɹˠ࠷ॳ͔ΒಡΈ࢝Ίͨͷ్͔த͔Βͳ ͷ͔ΔͨΊ(ޙड़) •
هࣄඇදࣔ࣌ͷඌ(px)ɹˠͲ͜·ͰಡΜͩͷ͔ΔͨΊ(ޙड़) • ಡྃ(%)ɹˠඌ/શମͷ͞
ૹΔλΠϛϯά • ը໘͕ݟ͑Δঢ়ଶ͔Βݟ͑ͳ͍ঢ়ଶʹͳͬͨ ͱ͖ • onPause࣌ or ViewPagerͷඇselect࣌Ͱ ૹΔ
Ͳ͏࣮͢Δͷ͔
ૹΔ • هࣄ͕ඇදࣔʹͳΔ·Ͱͷ࣌ؒɹˠ؆୯ͳλΠϚʔΫϥεΛ࡞ͬ ͨ • هࣄશମͷ͞ɹˠಡྃͷॏ͞ΛΔͨΊ • هࣄදࣔ࣌ͷઌ಄ɹˠ࠷ॳ͔ΒಡΈ࢝Ίͨͷ్͔த͔Βͳ ͷ͔ΔͨΊ(ޙड़) •
هࣄඇදࣔ࣌ͷඌɹˠͲ͜·ͰಡΜͩͷ͔ΔͨΊ(ޙड़) • ಡྃɹˠඌ/શମͷ͞ →View#getLocationInWindow →View#getLocalVisibleRect
Ͳ͏࣮͢Δͷ͔ • ઌ಄…View#getLocationInWindow • ඌ…View#getLocalVisibleRect • View#getScrollY →ಈతʹߴ͞ͷมΘΔϑολʔಡྃʹؚΊͳ͍ͨΊɺ ͑ͦ͏Ͱ͑ͳ͍
εΫϩʔϧྔͰͳ͘εΫϩʔϧ͞ΕͨViewͷҐஔͰஅ
View#getLocationInWindow • window্ͷViewͷࠨ্ͷ࠲ඪ(x,y)ΛྻͰऔಘ • ϔομʔΛͲ͜·Ͱ্ʹεΫϩʔϧ͔͕ͨ͠औΕΔ • yͰઌ಄Λऔಘ • val arr
= IntArray(2) view.getLocationInWindow(arr) val y = arr[1]
View#getLocationInWindow • ͍͍ͩͨͷ(x,y) (0,300) (0,1500) (0,-300) 1000x2000 ͷը໘ View x
y
View#getLocalVisibleRect • ViewͷՄࢹྖҬͷۣܗ(Rect)Λऔಘʢͪΐͬͱಛघʣ • ίϯςϯπ͕ͲΕ͘Β͍εΫϩʔϧ͞Ε͍ͯΔ͔औΕΔ • bottomͰඌΛऔಘ • val rect
= Rect() view.getLocalVisibleRect(rect) val position = rect.bottom
• ͍͍ͩͨͷ(left,top,right,bottom) View#getLocalVisibleRect (0,0,1000,400) (0,0,1000,400) (0,0,1000,200) (0,50,1000,2450) 1000x2000 ͷը໘ View
- - - - - - - - - - -
• ͍͍ͩͨͷ(left,top,right,bottom) View#getLocalVisibleRect (0,0,1000,400) (0,0,1000,400) (0,200,1000,400) (0,-450,1000,-50) 1000x2000 ͷը໘ View
- - - - - - - - - - -
εΫϩʔϧͷύλʔϯ
εΫϩʔϧঢ়ଶͷύλʔϯग़͠
ॳظঢ়ଶ
εΫϩʔϧঢ়ଶ1
εΫϩʔϧঢ়ଶ2
εΫϩʔϧঢ়ଶ3
εΫϩʔϧঢ়ଶ4
εΫϩʔϧঢ়ଶͷύλʔϯग़͠ • Ұݟ໘͚ͩͲެࣜΛग़ͤ؆୯
͍͞͝ʹ
FAQ • ͍ͯ͏͔ScrollViewʹWebViewೖΕ͍͍ͯͷʁ ˠͩΊͰ͢ɻby googler • ͡Ό͋͜ͷͲ͏ͳΔͷʁ ˠઈࢍॻ͖͑தͳͷͰࠓճڙཆ͞Ε·ͨ͠ • WebViewͱViewGroupΛΈ߹Θ͍ͤͨͱ͖ScrollView
Ͱғ͏Ҏ֎ରԠҊ͋Δͷʁ ˠ
DroidKaigi2019 ʮWebView+ViewGroupΛ࣮ݱ͢ΔAOSPϝʔϧ ɹΞϓϦͷ෦࣮ͱχϡʔεΞϓϦͷԠ༻ʯ ͱ͍͏λΠτϧͰ͢Αʂ
·ͱΊ • ฐ͍ࣾΖ͍Ζੳͯࠜ͠ڌ͋ΔࣈΛݩʹվ ળͯ͠ΔΑ • Viewͷදࣔঢ়ଶΛݟΔʹ getLocationInWindowgetLocalVisibleRectΛ ͏ͱ͍͍Α • ScrollViewʹWebViewೖΕͪΌବͩΑ