活动/片段转换是否与前棒棒糖设备兼容?
2022-09-01 09:00:39
我正在尝试使用前棒棒糖设备(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
有没有一个库已经为前棒棒糖实现了这一点?