diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 8e18957e..b89f58d7 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -32,6 +32,15 @@ public class MainActivity extends AppCompatActivity { NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment); // Animation + if (navHostFragment != null) { + MaterialSharedAxis exitTransition = new MaterialSharedAxis(MaterialSharedAxis.Z, true); + exitTransition.setDuration(500); + navHostFragment.setExitTransition(exitTransition); + + MaterialSharedAxis reenterTransition = new MaterialSharedAxis(MaterialSharedAxis.Z, false); + reenterTransition.setDuration(500); + navHostFragment.setReenterTransition(reenterTransition); + } BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java index a2023a02..8dca969c 100644 --- a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java @@ -11,6 +11,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.google.android.material.transition.MaterialSharedAxis; + /** * A simple {@link Fragment} subclass. * Use the {@link HomeTopFragment#newInstance} factory method to @@ -52,15 +54,14 @@ public class HomeTopFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Transition - TransitionInflater inflater = TransitionInflater.from(requireContext()); - setEnterTransition(inflater.inflateTransition(android.R.transition.slide_top)); - setExitTransition(inflater.inflateTransition(android.R.transition.slide_bottom)); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } else { - } + + MaterialSharedAxis enterTransition = new MaterialSharedAxis(MaterialSharedAxis.Z, true); + enterTransition.setDuration(500); + setEnterTransition(enterTransition); + + MaterialSharedAxis returnTransition = new MaterialSharedAxis(MaterialSharedAxis.Z, false); + returnTransition.setDuration(500); + setReturnTransition(returnTransition); } @Override