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
How to Load Image into Imageview from Url Using Glide V4.0.0Rc1
Partial Invalidation in Custom Android View with Hardware Acceleration
Insufficent_Storage_Memory Message While Install 50 Mb APK in Emulator
How to Get Preview in Composable Functions That Depend on a View Model
Fragment View in Viewpager Is Not Restored When Resuming
Gridlayoutmanager - How to Auto Fit Columns
How to Create an Android Activity and Service That Use Separate Processes
Obtain Root Access via Su on the Android Emulator
Failed to Execute Tools\Android.Bat: Solution
Ionic2 Background Image Is Resized When Keyboard Is Open
Resources and Layout Direction Rendered Incorrectly Only on Android 8.0 and Above
Firestorepagingadapter Not Receiving Realtime Updates
Android Studio - Error:Program Type Already Present