Android material 设计 - Material 运动
Android material design - Material Motion
我想制作一个包含项目列表的应用程序。当用户单击某个项目时,我想使用 here
中描述的 material 运动效果对其进行动画处理
android 库是否原生包含它?如果没有,请问有没有这个动画的3.party库?
您可以在这个视频中看到动画:
video link
您可以使用共享元素 Transition
https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition
https://github.com/googlesamples/android-ActivitySceneTransitionBasic
https://github.com/toddway/MaterialTransitions
https://github.com/afollestad/shared-element-transition-samples
FirstFragment fragmentOne = ...;
SecondFragment fragmentTwo = ...;
// Check that the device is running lollipop
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Inflate transitions to apply
Transition changeTransform = TransitionInflater.from(this).
inflateTransition(R.transition.change_image_transform);
Transition explodeTransform = TransitionInflater.from(this).
inflateTransition(android.R.transition.explode);
// Setup exit transition on first fragment
fragmentOne.setSharedElementReturnTransition(changeTransform);
fragmentOne.setExitTransition(explodeTransform);
// Setup enter transition on second fragment
fragmentTwo.setSharedElementEnterTransition(changeTransform);
fragmentTwo.setEnterTransition(explodeTransform);
// Find the shared element (in Fragment A)
ImageView ivProfile = (ImageView) findViewById(R.id.ivProfile);
// Add second fragment by replacing first
FragmentTransaction ft = getFragmentManager().beginTransaction()
.replace(R.id.container, fragmentTwo)
.addToBackStack("transaction")
.addSharedElement(ivProfile, "profile");
// Apply the transaction
ft.commit();
}
else {
// Code to run on older devices
}
输出
我想制作一个包含项目列表的应用程序。当用户单击某个项目时,我想使用 here
中描述的 material 运动效果对其进行动画处理android 库是否原生包含它?如果没有,请问有没有这个动画的3.party库?
您可以在这个视频中看到动画: video link
您可以使用共享元素 Transition
https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition
https://github.com/googlesamples/android-ActivitySceneTransitionBasic
https://github.com/toddway/MaterialTransitions
https://github.com/afollestad/shared-element-transition-samples
FirstFragment fragmentOne = ...;
SecondFragment fragmentTwo = ...;
// Check that the device is running lollipop
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Inflate transitions to apply
Transition changeTransform = TransitionInflater.from(this).
inflateTransition(R.transition.change_image_transform);
Transition explodeTransform = TransitionInflater.from(this).
inflateTransition(android.R.transition.explode);
// Setup exit transition on first fragment
fragmentOne.setSharedElementReturnTransition(changeTransform);
fragmentOne.setExitTransition(explodeTransform);
// Setup enter transition on second fragment
fragmentTwo.setSharedElementEnterTransition(changeTransform);
fragmentTwo.setEnterTransition(explodeTransform);
// Find the shared element (in Fragment A)
ImageView ivProfile = (ImageView) findViewById(R.id.ivProfile);
// Add second fragment by replacing first
FragmentTransaction ft = getFragmentManager().beginTransaction()
.replace(R.id.container, fragmentTwo)
.addToBackStack("transaction")
.addSharedElement(ivProfile, "profile");
// Apply the transaction
ft.commit();
}
else {
// Code to run on older devices
}
输出