Android实现界面组件的抖动效果
2016-01-03 14:36
471 查看
Android实现界面组件的抖动效果采用的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:toXDelta="10"
android:duration="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); //给组件播放动画效果
目录为 \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:toXDelta="10"
android:duration="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); //给组件播放动画效果
相关文章推荐
- MPAndroidChart 教程:ChartData类,ChartData子类, DataSet类,DataSet子类(十二)
- Android动画之Animator
- android 图片操作之BitmapMesh
- Gradle在Android Studio 的应用
- android 图片操作之Shader
- android 图片操作之Xfermode
- Android点击Button水波纹效果
- android图片操作之 Matrix
- Android常用数据库ORM框架ORMlite和GreenDao比较
- [置顶] Android 中触摸事件的分发和拦截
- Android Service学习之IntentService 深入分析
- Android图片上传的工具类
- Android HandlerThread 的使用及讲解
- Android ListView的简单实现
- Android线程问题及主线程与子线程的交互
- Android特效专辑(三)——自定义不一样的Toast
- Android特效专辑(三)——自定义不一样的Toast
- Android中SurfaceView的使用详解
- Android Handler removeMessages引发postDelayed失效的问题
- Android解析json