Android材质设计 - Material Motion

Kem*_*ran 4 android android-animation android-layout material-design android-design-library

我想制作一个包含项目列表的应用程序.当用户单击某个项目时,我想使用此处描述的材质运动效果为其设置动画

android库是否包含它本身?如果没有,这个动画有3个派对库吗?

您可以在此视频中看到动画: 视频链接

Adi*_*han 5

您可以使用共享元素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
}
Run Code Online (Sandbox Code Playgroud)

OUTPUT

在此输入图像描述