view抖动效果

1.使用属性动画

  ViewPropertyAnimator.animate(webView).translationX(20).setInterpolator(new CycleInterpolator(4)).setDuration(500).start();

2.使用xml动画---网上搜到的

 1.shake.xml

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

 2.cycle.xml

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

 3.代码实现

  Animation shakeAnim = AnimationUtils.loadAnimation(this, R.anim.shake);
  webView.startAnimation(shakeAnim);

posted on 2015-03-13 11:03  songsyl1207  阅读(320)  评论(0编辑  收藏  举报