Android: detailed animation inside a floating action button

I am trying to get acquainted with the new Android Lollipop design guidelines. So, especially for animations, I'm trying to achieve something like these detailed animations for icons or buttons: http://www.google.com/design/spec/animation/delightful-details.html

I was wondering how they did it.

In my special case, I have a button with a floating action that is used to delete an item in a shopping cart. After the user clicks the button, I want to animate the icon that can be retrieved inside this button. The animation should have a sliding effect when the cart moves to the bottom of the button and the checkmark moves to the top of the button.

enter image description hereenter image description here

I found ViewFlipper ( http://www.inter-fuser.com/2009/07/android-transistions-slide-in-and-slide.html ), however I want to keep the button in place and only animate the icon inside the button.

On the other hand, I found AnimationDrawables ( http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html ), but there I have to create each frame manually, which is also odd.

What is the best way to achieve this?

+6
source share
2 answers

I wonder if it can now support the support that you can now create yourself.

Create your own linear layout containing the image. Make it round like a fab. Then you can watch this animation.

Hope this helps. Happy encodings.

0
source

You can use frame animation: you create 15-20 frames for the animation you want to make. You create an animation list, for example, animation_list.xml:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:duration="50" android:drawable="@drawable/frame_01"/> <item android:duration="50" android:drawable="@drawable/frame_02"/> <item android:duration="50" android:drawable="@drawable/frame_03"/> <item android:duration="50" android:drawable="@drawable/frame_04"/> <item android:duration="50" android:drawable="@drawable/frame_05"/> <item android:duration="50" android:drawable="@drawable/frame_06"/></animation-list> 

Then you put it as src inside your custom FAB. Now you can start the frame-by-frame animation (when the FAB animation ends):

 ImageView mImageViewFilling = (ImageView) findViewById(R.id.animated_imageview); ((AnimationDrawable) mImageViewFilling.getBackground()).start(); 
0
source

Source: https://habr.com/ru/post/981712/


All Articles