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

Android实现界面组件的抖动效果

2014-11-11 14:24 267 查看
ADelta="10"
android:durndroid实现界面组件的抖动效果采用的Animation动画, 在系统提供的API Demos:
目录为 \android-sdk\samples\android-8\ApiDemos 中已经实现了简单的抖动效果 :

具体使用如下:
第一步:准备两个动画效果的XML文件,加入到 res/anim/目录下:

Shake.xml文件:
<translate xmlns:android="http://schemas.android.com/apk/res/android"

android:fromXDelta="0"

android:toXation="1000"

android:interpolator="@anim/cycle_7" />

cycle_7.xml文件:
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"

android:cycles="7" />

第二步: //代码使用动画效果:

Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);//加载动画资源文件

findViewById(R.id.xxxx).startAnimation(shake); //给组件播放动画效果
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: