在 material 卡片列表和细节 activity 之间添加动作

Add motion between a list of material cards and a detail activity

如何在这两个活动之间添加动作?

左:RecyclerView______________________右:DetailActivity

这些图像和样式来自 material 设计指南 https://codelabs.developers.google.com/codelabs/material-design-style/#0

这些指南对我帮助很大:https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition#1-enable-window-content-transitions

这是我的处理程序的代码

public void onCardClick(View view, Module module) {
    final Context context = view.getContext();
    final Intent intent = new Intent(context, DetailActivity.class);
    intent.putExtra(DetailActivity.MODULE, module);

    View image = view.findViewById(R.id.card_image);
    View description = view.findViewById(R.id.card_description);

    Pair<View, String> p1 = Pair.create(image, "image");
    Pair<View, String> p2 = Pair.create(description, "description");

    ActivityOptionsCompat options = ActivityOptionsCompat
            .makeSceneTransitionAnimation(mActivity, p1, p2);

    context.startActivity(intent, options.toBundle());
}

我还在我的两个活动中添加了 transitionName

<ImageView
    android:id="@+id/card_image"
    android:transitionName="image" />

<TextView
    android:id="@+id/card_description"
    android:transitionName="description" />