Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android实现界面组件的抖动效果

Android实现界面组件的抖动效果采用的Animation动画, 在系统提供的API Demos:目录为  android-sdksamplesandroid-8ApiDemos 中已经实现了简单的抖动效果 :具体使用如下:第一步:准备两个动画效果的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); //给组件播放动画效果