在 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
这是我的处理程序的代码
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" />
如何在这两个活动之间添加动作?
左:RecyclerView______________________右:DetailActivity
这些图像和样式来自 material 设计指南 https://codelabs.developers.google.com/codelabs/material-design-style/#0
这是我的处理程序的代码
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" />