2

我想製作一個包含項目列表的應用程序。當用戶點擊一個項目時,我想用動畫效果爲其製作動畫效果hereAndroid材質設計 - 材質動作

是android庫包含它原生?如果沒有,這個動畫是否有一個3方圖書館?

你可以看到在這個視頻動畫: video link

+1

參見**具有共享元件開始一個活動**在https://developer.android.com/training/material/animations.html部 – Virat18

回答

3

您可以使用共享元素過渡

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 
} 

OUTPUT

enter image description here