I was reading the "Selection" section in material design guidelines (https://material.io/guidelines/patterns/selection.html), and one effect i wanted to add in my app was the circular reveal animation while switching between the app bar and the ActionMode ? An other toolbar ?
Here is an example from the guidelines: https://storage.googleapis.com/material-design/publish/material_v_10/assets/0Bwp7jtSjaW36RGF3eUFsRkdqU1U/patterns_selection_item_controlling_desktop_click.webm
I didn't found any explanations about how to do that. I do not even know if they use an ActionMode or something else...
Is there someone who could give me the good direction to follow ?
edit: minSdk 21
edit 2: look at the status bar which also changes itself...
Thanks François
You can use custom ripple library for such animation. It can be found here.
Then, to have the same effect, your toolbar will reside in rippleview, as given in the instructions of custom library. You need to have coordinates from where ripple effect should begin, for your case, this coordinate is the center of floating action button with plus symbol. Then, on item selection, run this ripple animation and fade in floating action button, you will have same effect.
Some similar examples can be seen on above mentioned library page.
Hope it helps !
Ok finally i found a solution.
It is not a very good one... but i have no other idea to use something else so if you have some other tips to share... you're welcome!
Here is the final result and code below:
Sample project on GitHub
https://github.com/fbourlieux/android-material-circular_reveal_animation
Goal & idea
Switching from a toolbar to another one by using a "smooth" circular revealed animation. That animation need to update the app bar AND status bar.
To do so, first we need to force the activity to display it content under the status bar by using
android:fitsSystemWindows=false
property on the main layout container and<item name="android:windowTranslucentStatus">true</item>
in the App theme. Based on that we will not only create aToolbar
but also a view that will be displayed under the statusBar, juste to draw a nice background during the animation. Here is the point i don't like in my sample, but i didn't found any other solution.Let's see the code
styles.xml
we just added the
android:windowTranslucentStatus
property.app_bar_main.xml
Create 2 overlapped layout that contains a view to draw the status bar and a view to draw the toolbar. By default, the layout to animate is set invisible.
MainActivity.java
So in
MainActivity
, after having listen the onclick event of myToggleButton
, i trigger the animation of my second toolbar group (status view + toolbar) by usingViewAnimationUtils.createCircularReveal
methods. First argument is the view to animate, followed by the start coordinate of the animation and followed by the radius.In onClick method i also launch a
reverse
animation when i click on the arrow or a second time on my ToggleButton.Finally it is a pretty simple solution even if we need to fake the status bar background.
Hope my solution could help someone.
François
Userful links: