Android - 共享元素过渡在对话框中 [英] Android - Shared Element Transition In Dialog

查看:532
本文介绍了Android - 共享元素过渡在对话框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有办法在活动/片段和对话框之间使用共享元素?



我有一个包含对话框的项目,我想在Activity视图层次结构中的ImageView与GalleryDialog中相关的ImageView之间进行转换。



我搜索了一下,发现了这个链接:



使用对话框活动共享元素转换



其中描述了使用对话主题活动的工作流程。我想知道我是否可以在没有使用额外的活动并且意图传递数据的情况下执行此操作。

解决方案

AFAIK不可能在片段/活动和对话框之间使用共享元素。
实现这一点的最好方法是您提到的链接,使用一个以对话框为主题的活动,看起来像一个对话框,并通过意图将数据发送到acctivity。



为了意图发送大数据,您可以使用包裹或外部存储数据,例如单身类或数据库。
看看以下关于在活动之间传输大数据的答案:



Android - 在活动之间共享数据的最佳方式是什么?


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.

解决方案

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?

这篇关于Android - 共享元素过渡在对话框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆