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
62
DnD in Compose
punchdrunker
0
340
what's new in Material Design で気になったトピック
punchdrunker
1
650
7カ国語に対応したサービスでの翻訳管理システムの改善事例
punchdrunker
1
1.6k
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
750
レビュー評価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
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
270
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
160
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
110
不幸な GC
chencmd
0
660
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1k
メールのエイリアス機能を履き違えない
isshinfunada
0
250
今さら聞けない .NET CLI
htkym
0
210
リアルな遅延を測る仕様
kota_yata
1
120
Press start. Python's next generation.
willingc
PRO
2
110
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
510
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
480
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
470
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
280
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Making the Leap to Tech Lead
cromwellryan
135
10k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
The Curious Case for Waylosing
cassininazir
1
480
Building Flexible Design Systems
yeseniaperezcruz
330
40k
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