Android: makeSceneTransition 用于多个共享元素

Android: makeSceneTransition for more than one shared elements

我一直在尝试使用 android 网站上显示的示例在多个共享元素上实现动画过渡

    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this,
    Pair.create(view1, "agreedName1"),
    Pair.create(view2, "agreedName2"));

但是当我尝试在 Eclipse IDE 中的示例应用程序上实现此代码时,它说

The method makeSceneTransitionAnimation(Activity, View, String) in the type ActivityOptions is not applicable for the arguments (MyActivity, Pair<View,String>, Pair<View,String>)

我需要一些帮助。谢谢

我刚遇到同样的问题。在我的例子中,我导入了

import android.support.v4.util.Pair;

而不是

import android.util.Pair;

在我的案例中,我试图传递 imageViewlinearLayout,而该方法期望 Views.

所以我做到了,View view1 = imageView;View view2 = linearLayout。 并将它们传递给方法。