我正在尝试在棒棒糖之前的设备 (4.x) 上使用共享元素进行活动转换。可能吗?到目前为止,我正在尝试这个:
public class RewardDetail extends ActionBarActivity {
@Override
public void onCreate(final Bundle savedInstanceState) {
...
ViewCompat.setTransitionName(imageView, TRANSITION_NAME);
}
...
public static void launch(ActionBarActivity activity, View transitionView, WelcomeReward detailData) {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionView, TRANSITION_NAME);
Intent intent = new Intent(activity, RewardDetail.class);
intent.putExtra(PARAM_DATA, detailData);
ActivityCompat.startActivity(activity, intent, options.toBundle());
}
}
调用者:
@Override
public void onClick(final View v) {
int position = recyclerView.getChildPosition(v);
WelcomeReward welcomeReward = data.get(position);
RewardDetail.launch(WelcomeRewardActivity.this, v.findViewById(R.id.reward_view), welcomeReward);
}
但它会导致“常规”转换(没有共享元素)。有任何想法吗?
编辑
根据这个视频,它可以做到:
https://www.youtube.com/watch?v=RhiPJByIMrM&index=8&list=WL
是否有一个图书馆已经为 pre Lollipop 实现了这个?