How can i animate hamburger drawer icon - android

I have to animate a drawer icon. The red circle needs to pop up in the same way as in the gif below. Any of the animation styles are fine, I only want to know if I can create an animation like these. Any thoughts?
I have searched the internet, but I haven't found anything so far.

You could try using the scale animation, for example, to get a similar effect of the pop animation in that gif you could do the following:
Create a file res/anim/bounce.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/bounce_interpolator">
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800"
android:fromXScale="1.5"
android:fromYScale="1.5"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
</set>
And then load the animation:
Animation bounceAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.bounce);
yourView.startAnimation(bounceAnimation);

Related

How to make shaking animation on android like iOS has?

Does anybody has an example of animation that looks like tilting slightly on left and right but middle is not moving. It looks like when you want to move icons on iOS and make a long press you could see that kind of animation what I need. I got animation but it more looks like moving the whole item instead of tilting. Here is my code
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="70"
android:interpolator="#android:anim/linear_interpolator"
android:pivotX="40%"
android:pivotY="40%"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toDegrees="1" />
<translate
android:duration="70"
android:fromXDelta="-3"
android:fromYDelta="3"
android:interpolator="#android:anim/linear_interpolator"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toXDelta="0.1" />
</set>
Its like wiggling effect on this screen
The rotation effect can be made by adding 2 parameters
android:fromDegrees="0"
android:toDegrees="3"

i want implement animation for Floating Button

I want to give a full rotation animation to my floating button, i have the code, but its only animating like rotating half. i want rotate the floating button from a position and it should end with the same position where it started( a full rotation ) , how to do that ?
here is my code , i want some one to modify the value or code
final OvershootInterpolator interpolator = new OvershootInterpolator();
ViewCompat.animate(fab).
rotation(170f).
withLayer().
setDuration(1000).
setInterpolator(interpolator).
start();
Make rotate.xml in res/anim:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:duration="1000" />
</set>
Then in code:
FloatingActionButton mFloatingButton = view.findViewById(R.id.myFloatingButton);
Animation mAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);
mFloatingButton.startAnimation(mAnimation);

how to create FAB reveal animation like Google keep and Inbox by gmail

I am trying to create FAB animations like shown in Google design guidelines such as circular reveal, morph animations (google keep and inbox) in API Level 15. I used google design support library to add FAB icon to my app.
I would appreciate your help in this regard. Thanks.
The FAB animation is actually a simple scale animation that you can write yourself, something like this:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/linear_interpolator">
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="250" />
</set>
That goes in an xml in the "anim" folder.
And then you animate the button in the java code:
final Animation mAnimation = AnimationUtils.loadAnimation(context, R.anim.animation_name);
yourFab.setVisibility(View.VISIBLE); //It has to be invisible before here
yourFab.startAnimation(mAnimation);

Make the navigation bar stay on top of any activity animation

First of all I'm working with the Android-L preview. Now, For anyone to not to misunderstand what navigation bar is, here's a pic of it:
https://imageshack.com/i/f0bjjDnQp
I'm applying the activity animation that follows:
activity.startActivity(intent);
activity.overridePendingTransition(R.anim.slide_in_from_bottom, R.anim.scale_in);
Where R.anim.slide_in_from_bottom.xml is:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromYDelta="100%"
android:toYDelta="0%"/>
</set>
and R.anim.scale_in is:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="300"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.9"
android:toYScale="0.9"/>
<alpha
android:duration="300"
android:fromAlpha="1.0"
android:interpolator="#android:anim/accelerate_interpolator"
android:toAlpha="0.1"/>
</set>
The animation works fine except for the fact that the new activity does the animation on top of the navigation bar, I'd like it to be the opposite. Also I can see the black status bar during the whole animation which I would like to avoid too.
UPDATE:
So I found what the problem is. With the introduction of Android L preview we have the option to set this Material theme, and that theme makes the animations between activities this way. If I set android:Theme.Holo.Light for instance, everything works fine. As soon as I add this Material theme I got this ugly effect of overlaying the Navigation Bar.
So I thought I could try to find the right parameter in the Material Theme to make it behave as the old theme but I can't manage to figure it out. I've tried setting this line below, but it doesn't work either.
<item name="android:windowActionBarOverlay" >false</item>

Avoid animation automatically "unwinding"?

I've a simple view animation, but I can't see to get "rid" of the animation "unwinding" (and I can't seem to find a solution online).
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/linear_interpolator"
android:shareInterpolator="true" >
<scale
android:duration="250"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:toXScale="1.1"
android:toYScale="1.1" />
</set>
What this does is, simply, inflates the View by 10% proportionally, from the middle.
But, when it executes, it inflates and, when it reaches the end, it deflates back. I want to avoid that -- the "unwinding" effect -- when it scales back from 110% to 100%.
How can that be done?
Edit:
I'm starting it simply with this:
Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.<name>);
v.startAnimation(animation1);
The correct answer is found here: How can I animate a view in Android and have it stay in the new position/size?
It is putting this:
android:fillAfter="true"
android:fillEnabled="true"
inside the <set tag.

Categories

Resources