Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Practical Activity Transition in Android
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
punchdrunker
March 08, 2019
Programming
1.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Practical Activity Transition in Android
punchdrunker
March 08, 2019
More Decks by punchdrunker
See All by punchdrunker
Kotlin2.0以降の新機能
punchdrunker
0
48
DnD in Compose
punchdrunker
0
330
what's new in Material Design で気になったトピック
punchdrunker
1
650
7カ国語に対応したサービスでの翻訳管理システムの改善事例
punchdrunker
1
1.5k
Java Bytecode Vertical Tasting
punchdrunker
2
1.6k
getting started with dark theme
punchdrunker
2
1.1k
今時のProgress indicator / Replacing ProgressDialog with ProgressBar
punchdrunker
0
740
レビュー評価4.7の秘密 / The Secret To A Better Reputation
punchdrunker
2
2.1k
Dynamic Feature Modules 入門
punchdrunker
2
2.8k
Other Decks in Programming
See All in Programming
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
490
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
760
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
CSC307 Lecture 17
javiergs
PRO
0
320
Inside Stream API
skrb
1
710
3Dシーンの圧縮
fadis
1
770
AI時代のUIはどこへ行く?その2!
yusukebe
21
7.2k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
160
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
120
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
250
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
250
Featured
See All Featured
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
190
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
840
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
370
Navigating Weather and Climate Data
rabernat
0
220
Site-Speed That Sticks
csswizardry
13
1.2k
Ruling the World: When Life Gets Gamed
codingconduct
0
250
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
350
Thoughts on Productivity
jonyablonski
76
5.2k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Rails Girls Zürich Keynote
gr2m
96
14k
Transcript
Practical Transition by punchdrunker
ࣗݾհ —2010ʙ iOS/AndroidͷΞϓϦΛॻ͍ͯΈΔ —2011ʙ SNS mixi(ϛΫγΟ) —2016ʙ ՈΞϧόϜ ΈͯͶ(ϛΫγΟ) —DroidKaigiͱ͔shibuya.apkΛӡӦ
Sample code —https://github.com/punchdrunker/hocho —android-transition-examples —https://github.com/google/android-transition- examples
࣍ —SharedElementΛ͏·ͰͷܦҢ —༻ޠղઆ —͓खຊ —جຊతͳ͍͔ͨ —࣮ࡍͷΞϓϦͷద༻ —ͷղܾ๏ͱఘΊͨࣄ —·ͱΊ
ܦҢ ࣸਅҰཡը໘͔Βࣸਅͷৄࡉը໘ʹભҠͨ࣌͠ʹ... —Fling to finish(্ԼεϫΠϓͰด͡Δ)Λ࣮͍ͨ͠ —Ͳ͏ͤͳΒਮͳΞχϝʔγϣϯԋग़ग़དྷΔͱخ͍͠ —υΩϡϝϯτ௨Γʹॻ͍ͯΔͷʹಈ͔Μ!!!!1 —ॻ͍ͨ௨Γʹಈ͍ͯ·ͨ͠(ল) x 100
—શʹཧղͨ͠!! —࠳ં
༻ޠͷઆ໌(1) —Transition framework(ભҠ) —ը໘ભҠͰϨΠΞτʹΞχϝʔγϣϯޮՌΛ͚ Δ͜ͱͰ͖ΔϑϨʔϜϫʔΫͷ૯শ —minSdkVersion 21 —Transition —Transition ManagerʹΑͬͯཧ͞ΕΔɺ"ભ
Ҡ"ͦͷͷ
༻ޠͷઆ໌(2) —SharedElement(View) —ભҠݩͱભҠઌͰܨ͗߹Θ͍ͤͨViewɻoptionͱ ͯ͠startActivityʹ͢ɻ —Transition name(String) —ભҠݩͱભҠઌͷViewʹಉ͡transitionNameΛ ͚ΔࣄͰSharedElementͱͯ͠ೝࣝ͞ΕΔ
͓खຊʹͨ͠ͷ —android-transition-examples —https://github.com/google/android-transition- examples —twitterެࣜΫϥΠΞϯτ
جຊతͳ͍ํ
Transitionͷύλʔϯ —Fragment to Fragment —Activity to Activity
Fragment to Fragment 1ͭͷActivityͰͷભҠgoogle example͕ྫɻ ભҠ͢Δ࣌ͷFragmentManagerʹaddSharedElement ϝιουͰભҠݩͷImageViewͱtransitionNameΛϖ ΞͰηοτ͢Δɻ ભҠઌͰಉ༷ɻ (transitionNameͷઃఆίʔυଆ͔ΒͰϨΠΞτ
xml͔ΒͰՄೳɻ)
Fragment to Fragment ࣮ྫ ImageView transitioningView = view.findViewById(R.id.card_image); fragment.getFragmentManager() .beginTransaction()
.setReorderingAllowed(true) // Optimize for shared element transition .addSharedElement( transitioningView, transitioningView.getTransitionName()) .replace( R.id.fragment_container, new ImagePagerFragment(), ImagePagerFragment.class.getSimpleName()) .addToBackStack(null) .commit();
sampleͷಈ͖
Activity to Activity transitionNameΛϖΞͰઃఆ͢Δͷಉ͡ɻ startActivityͷoptionͱͯ͠ɺsharedElementΛϖΞʹ ͨ͠bundleΛ͢ɻ ෳ͚ͨ͠ΕPairܕͰՄมҾͱͯͤ͠Δɻ val intent =
ToActivity.createIntent(context, position) val option = ActivityOptions.makeSceneTransitionAnimation( activity, view, getString(R.string.shared_element)).toBundle() startActivity(intent, option)
࣮ࡍͷΞϓϦͷద༻ ͱͱͷ༷ —RecyclerViewͰࣸਅΛάϦουදࣔ —ભҠͨ͠ઌͷৄࡉը໘ͰࠨӈʹεϫΠϓ͢Δͱࣸਅ ΛҠಈͰ͖Δ(ViewPager) —εϫΠϓͨ͠ޙʹը໘Λดͯ͡ϦετʹΔͱɺͦͷ ҐஔʹεΫϩʔϧ͍ͯ͠Δ
ͱͦͷղܾ๏ ͔͜͜ΒαϯϓϧΛݟͳ͕Βղઆ͠·͢(item1&2&3)
AppBar/ϑολ͔ͿΔ ্ԼʹॏͳΔView͕͋ͬͨΒεΫϩʔϧͰճආ private fun shoulScrollList(cell: View): Boolean { val cellLocation
= IntArray(2) cell.getLocationOnScreen(cellLocation) val cellTop = cellLocation[1] val listLocation = IntArray(2) binding.list.getLocationOnScreen(listLocation) val diffToAppBar = cellTop - listLocation[1] val cellBottom = cellTop + binding.list.height val listBottom = listLocation[1] + binding.list.height val diffToBottom = cellBottom - listBottom return (diffToAppBar < 0 || diffToBottom > 0) }
ViewPagerͰࠔΔ͜ͱ —item4Ͱ͕ൃੜ͢Δ —ճආࡦΛitem5ͰରԠ
εϫΠϓͨ͠ޙʹΓઌͷImageViewΛมߋ͢Δʹ ίʔϧόοΫͰಈతʹมߋͰ͖Δ
ViewPagerͱͷ࿈ܞ ඞਢίʔϧόοΫ —setEnterSharedElementCallback —setExitSharedElementCallback FragmentManagerΛͬͨભҠͰɺFragmentͰར ༻ startActivityΛͬͨભҠͰɺActivityͰར༻
ίʔϧόοΫͰԿ͕ग़དྷΔ͔ ඥ͘SharedElementΛಈతʹมߋͰ͖Δ setExitSharedElementCallback(object : SharedElementCallback() { // names: List<String>, sharedElements:
MutableMap<String, View> override fun onMapSharedElements(names: ..., sharedElements: ...) { val viewHolder = fromFragment?.getViewHolder(newPosition) val itemView = viewHolder?.itemView ?: return val photoView = itemView.findViewById<ImageView>(R.id.card_photo) sharedElements[names[0]] = photoView } })
ίʔϧόοΫͷλΠϛϯά —Activity A(Ұཡ)͔ΒActivity B(ৄࡉ)ʹભҠ —AͷExitSharedElementCallback͕ݺΕΔ —BͷEnterSharedElementCallback͕ݺΕΔ —B͔ΒAʹΔ —BͷEnterSharedElementCallback͕ݺΕΔ —AͷExitSharedElementCallback͕ݺΕΔ
ͳͥ? Δ࣌ͷActivity Transitionདྷͨ࣌ͷanimationΛ reverse͢Δҝ (finishAfterTransition ͋ͨΓΛಡΉͱॻ͍ͯ͋Δ)
͞ΒʹεΫϩʔϧ͕ඞཁ ఘΊͨ
None
͞ΒͳΔ Transition Animation ͕X?????a ܥͷͰ·ͱʹ ಈ͔ͳ͔ͬͨ !
ղࢄ
FIN