【问题标题】:Android material design - Material MotionAndroid 材料设计 - Material Motion
【发布时间】:2017-10-06 05:12:17
【问题描述】:

我想制作一个包含项目列表的应用程序。当用户点击一个项目时,我想用here中描述的材质运动效果对其进行动画处理

android 库是否以原生方式包含它?如果没有,是否有这个动画的 3.party 库?

您可以在此视频中看到动画: video link

【问题讨论】:

标签: android android-layout material-design android-animation android-design-library


【解决方案1】:

你可以使用共享元素过渡

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
}

输出

【讨论】:

    猜你喜欢
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-27
    相关资源
    最近更新 更多