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