您的位置:首页 > 移动开发 > Android开发

android 实现左右上下震动的效果

2013-05-23 17:38 183 查看
1:在acti里调用代码

Animation shakeAnim = AnimationUtils.loadAnimation(mContext, R.anim.shake_y);
passWd.startAnimation(shakeAnim);

2:在anim目录下的shake_y.xml

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

</translate>

3在anim下的cycle.xml文件:

cycles值用来控制摆动的幅度

<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="200" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: