Hello, in this video, I will be talking about animations for the Navigation Component.
Hello, in this video, I will be talking about animations for the Navigation Component.
https://codeible.com/view/tutorial/9ebiqezy9ewNojdb3I81;title=Android%20-%20Navigation%20Component
Lastly, add an action.
Find an image you can use and drag the image file into the drawable folder under the resource directory.
Switch back to the design view and add an image view for the image you placed in your project. Add the constraints, set the width and height 200dp, and then set the scale type to center crop.
Lastly, go into the page 1 fragment class file and add a reference to the image view.
If we run the application and click on the image, we should transition to page 2.
Adding Animations
To add animations, go to the navigation graph.
We can type anim and we will see some animations that were provided for us.
If we run the application, we will have a slide effect.
Custom Animations
Give the file a name and change the resource type to Animation.
This will create an anim directory with our xml animation file inside.
Then I want it to end up at 0 pixels.
If we run the application, it will move from left to right but at a slower pace.
Shared Element Transitions
And third, we need to set the type of animation we want to use for the views during the transitioning phase.
In our example, we have a small image view in page 1 and a larger image view in page 2.
If you have more than 1 view that you are trying to animate, call the method multiple times to add them.
Lastly, set the animation you want to use for the view.