Android - Shared Element Transition In Dialog

梦想的初衷 提交于 2019-11-30 14:20:44

问题


I wanted to know if there is any way to use shared elements between an activity/fragment and a dialog?

I have a project which contains dialogs and I want to make a transition between an ImageView in Activity's view hierarchy to the relevant ImageView in my GalleryDialog.

I searched a bit and found this link:

Shared element transition with Dialog Activity

which describes the workflow for using dialog themed activity. I was wondering if I could do it without using an extra activity and passing data with intent to that activity.


回答1:


AFAIK its impossible to use shared elements between a fragment/activity and a dialog. The best way implement this is the link you mentioned, using a dialog-themed activity that looks like a dialog and send data via intent to the acctivity.

For sending large data with intent, you can either use parcelables or an external place to store data, e.g. a singleton class or a database. Have a look at the following answer regarding transferring large data between activities:

Android - What's the best way to share data between activities?



来源:https://stackoverflow.com/questions/33596296/android-shared-element-transition-in-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!