Shaking/Wobble View Animation in Android

shaking / wobble view animation in android

Try setting android:repeatMode="reverse". Below animation gives a very reasonable immitation on my Galaxy Nexus. Obviously you can fine tune the parameters to your own liking.

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="100"
android:fromDegrees="-5"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toDegrees="5" />

How to achieve shake animation programmatically?

let's say that mView is the view you want to animate:

ObjectAnimator
.ofFloat(mView, "translationX", 0, 25, -25, 25, -25,15, -15, 6, -6, 0)
.setDuration(duration)
.start();

How can I make vibrate animation for ImageView

This code shakes a view in horizontal direction

shake.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_5"
android:toXDelta="10" />

cycle_5.xml

<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="5" />

Method to shake ImageView

public void onShakeImage() {    
Animation shake;
shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.shake);

ImageView image;
image = (ImageView) findViewById(R.id.image_view);

image.startAnimation(shake); // starts animation
}

android animation like wiggle/shake while Deleting

You could easily do this by implementing a TanslateAnimation and just having it repeat a few times. Translate animations are for moving things around on the screen in a 2d plane. So just make the x coordinate modulate between a given interval. You can also implement an AnimationSet to group a few animations together such as two translate animations one to move it right one to move it left.



Related Topics



Leave a reply



Submit