On the android material design principles page, one of the examples shows a FAB expanding into a new full screen. (Under "Full Screen")
I've tried to implement the same effect in my app, but with little success.
I managed to create a FAB that expands into a view using this code as reference: https://gist.github.com/chris95x8/882b5c5d0aa2096236ba.
It worked, but I was wondering whether I could apply the same effect to an activity transition. I've tried looking it up and playing with it myself but could not find anything that might work.
I know I could make the FAB expand into a Fragment and not a whole new activity, but I'm not sure if that's what being done, and whether that's optimal or not.
And so my question is, is there a way to implement the fab-expanding reveal effect as an activity transition, or is it supposed to just reveal a new fragment?
you can use this lib [https://github.com/sergiocasero/RevealFAB][1]
[1]: https://github.com/sergiocasero/RevealFAB 3rd party its easy and simple to use
Add to your layout
Important: This component goes above your content. You can use Coordinator, LinearLayout... or another Relative layout if you want :)
As you can see, you have 3 custom attributes for customizing colors and icon
Setting information about intent:
Don't forget call onResume() method!
I made a custom activity, based on this question Circular reveal transition for new activity , that handle the CircularRevealAnimation and his reverse effect when the activity finish:
You can extend this with your own activity and call in your onCreate the method 'showRevealEffect' like this:
You also have to use a transparent theme like this one:
In the end, to launch this activity you should pass via extra the coordinates where the animation should start:
I am developing an app which expands a
FloatingActionButton
into a newActivity
. I'm not sure that if you like my implementation, but please see pictures at first:So the first picture shows
MainActivity
and the last one showsSecondActivity
, which is "expanded" from FAB.Now, I want to mention that I'm not actually expanding a FAB into a new
Activity
but I can let user feel that the new page is expanded from that FAB, and I think that's enough for both developers and users.Here's implementation:
Preparation:
FloatingActionButton
of course,BakedBezierInterpolator
to control reveal animation and make it material-styled.Steps:
create activity_main.xml like this:
find Views:
expand when user clicks FAB:
And here is hold.xml in res/anim:
That's all.
Improvements:
RevealLayout
has a bug(plays rectangular instead of circular reveal animation) for devices under API 17(Android 4.2), you can add these lines in constructor of it:If your
SecondActivity
contains complicated contents, a simpleView
used as reveal_view in the layout.xml isn't enough/perfect. You can include the second layout inside theRevealLayout
reveal_layout. It seems wasteful and hard to control if the second layout won't appear same at every time. But for me, it will. So you can make other improvements if you should.If you want to implement totally same animation shown in Material Design Guide, you can set layout_height of the
RevealLayout
into a specific number instead of match_parent. After expanding animation ends(or some time after the animation plays, which should make the whole process of animation smoothly), then you can animate translationY. The important point is, just cheat users visually by controlling animation duration.Finally, this is my own experience/attempt and I'm a beginner in developing Android apps. If there are any mistakes/further improvements, please leave comments/edit my answer. Thank you.