問題描述
我想知道是否有任何方法可以在活動/片段和對話框之間使用共享元素?
I wanted to know if there is any way to use shared elements between an activity/fragment and a dialog?
我有一個包含對話框的項目,我想在 Activity 的視圖層次結構中的 ImageView 到我的 GalleryDialog 中的相關 ImageView 之間進行轉換.
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:
與對話框活動共享元素轉換
它描述了使用對話主題活動的工作流程.我想知道是否可以在不使用額外活動并將數據傳遞給該活動的情況下做到這一點.
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 不可能在片段/活動和對話框之間使用共享元素.實現這一點的最佳方法是您提到的鏈接,使用看起來像對話框的以對話框為主題的活動,并通過意圖向活動發送數據.
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.
對于有意發送大數據,您可以使用 parcelables 或外部位置來存儲數據,例如單例類或數據庫.查看以下有關在活動之間傳輸大數據的答案:
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 - 在活動之間共享數據的最佳方式是什么?
這篇關于Android - 對話框中的共享元素轉換的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!