I want to create animation for my fab like this example in material design principle, I realized that icon inside fab has 2 animation. One that rotate share icon and another is alpha animation simultaneity. after that another icon replaced. but when I create animation set for this goal, whole fab rotated and disappeared, but I want that icon inside fab take this animation. How can I create this animation? thanks
Asked
Active
Viewed 2,842 times
2 Answers
1
The best way to achive that is create a Custom Floating action button class and Override your setImageDrawable
method, doing the translation animation there. Also you can modify your onDraw method to add an animation to your FloatingActionButton

Francisco Durdin Garcia
- 12,540
- 9
- 53
- 95
-
thanks for your response. I am trying this solution. – Saber Solooki May 26 '16 at 16:06
-
Hope it will help you ;) If you want to check how to override onDraw, you can take a look to this post: http://stackoverflow.com/questions/37263308/pulsating-button-animation-android I overrided my custom class onDraw to generate a pulsating animation. In you case you must to use a move and alpha animation using onDraw or setImageDrawable – Francisco Durdin Garcia May 26 '16 at 16:10
-
whenever I call setImageDrawbale this animation should animated, right? for example when I click on fab, I call fba.setImageDrawable and play this animation, right? – Saber Solooki May 26 '16 at 16:24
-
if you add the call to your animation in your onclicklistener, yes – Francisco Durdin Garcia May 26 '16 at 19:21
1
You have to use a third-party library to achieve this result. Take a look here
It is important to notice that it is possible to implement your own way but you would be kind of "reinventing the wheel".
If you want to do this anyway, you can create several FABs and change visibilities and move them with simple animations.

rafaelc
- 57,686
- 15
- 58
- 82
-
thanks for your cool library offer. I certainly check this library – Saber Solooki May 26 '16 at 16:08