插补器Interpolator

官网描述:An interpolator defines the rate of change of an animation. This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated, etc.

Google翻译:Interpolator可以限定一个动画的变化率。 这样的话,可以对基本的动画效果(比如透明、缩放、位移、旋转)进行加速、减速、重复等

参考APIDemo中Views>Animation>Interpolator

下图是Interpolator的一些属性,可以对动画中Interpolator属性设置为以下资源内容,实现动画效果。

实例:(对输入框实现摇晃效果)

anim/cycle_7.xml

 <?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="7" /> //周期运动7次

anim/shake.xml

 <?xml version="1.0" encoding="utf-8"?>

 <translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_7" //设置该动画从x到y移动10,来回7次。
android:toXDelta="10" />

R.id.pw为一个EditText。

 public void onClick(View v) {
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
findViewById(R.id.pw).startAnimation(shake); //给输入框pw设置动画属性
}

--------------------------------------------------------------------------------------------------------------------------------------------------

插补器Interpolator

代码实现(对动画对象设置一个插补器,并实现插补器中的getInterpolation方法。该方法主要是数学知识,描述物体运动轨迹的计算公式,比如正弦,余弦,或者y=x等)

 Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
shake.setInterpolator(new Interpolator() { @Override
public float getInterpolation(float x) {
//实现插补器的逻辑
int y = x;
return y;
}
});
10 findViewById(R.id.pw).startAnimation(shake);

Android开发之View动画效果插补器Interpolator的更多相关文章

  1. 【Android UI】Android开发之View的几种布局方式及实践

    引言 通过前面两篇: Android 开发之旅:又见Hello World! Android 开发之旅:深入分析布局文件&又是“Hello World!” 我们对Android应用程序运行原理 ...

  2. Android开发之View重写相关API-onLayout,onMeasure,MeasureSpec

     1.onLayout android.view.ViewGroup protected void onLayout(boolean changed, int l, int t, int r, int ...

  3. Android 动画之View动画效果和Activity切换动画效果

    View动画效果: 1.>>Tween动画通过对View的内容进行一系列的图形变换(平移.缩放.旋转.透明度变换)实现动画效果,补间动画需要使用<set>节点作为根节点,子节点 ...

  4. Android开发之PopupWindow

      /* *  Android开发之PopupWindow * *  Created on: 2011-8-8 *  Author: blueeagle *  Email: liujiaxiang@g ...

  5. android开发之Animations的使用(二)

    android开发之Animations的使用(二) 本博文主要讲述的是android开发中的animation动画效果的使用,和上一篇博文不同的是,此次四种动画效果,主要使用的是xml文件实现的,提 ...

  6. android开发之Animation(五)

    android开发之Animation的使用(五) 本博文主要讲述的是Animation中的AnimationLisenter的用法,以及此类的一些生命周期函数的调用,代码实比例如以下: MainAc ...

  7. Android开发之InstanceState详解

    Android开发之InstanceState详解   本文介绍Android中关于Activity的两个神秘方法:onSaveInstanceState() 和 onRestoreInstanceS ...

  8. Android开发之ViewPager+ActionBar+Fragment实现响应式可滑动Tab

     今天我们要实现的这个效果呢,在Android的应用中十分地常见,我们可以看到下面两张图,无论是系统内置的联系人应用,还是AnyView的阅读器应用,我们总能找到这样的影子,当我们滑动屏幕时,Tab可 ...

  9. android中设置Animation 动画效果

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

随机推荐

  1. python(三)一个文件读写操作的小程序

    我们要实现一个文件读写操作的小程序 首先我们有一个文件 我们要以"============"为界限,每一个角色分割成一个独立的txt文件,按照分割线走的话是分成 xiaoNa_1. ...

  2. 详解AngularJS中的filter过滤器用法

    系统的学习了一下angularjs,发现angularjs的有些思想根php的模块smarty很像,例如数据绑定,filter.如果对smarty比较熟悉的话,学习angularjs会比较容易一点.这 ...

  3. a标签点击后的虚线框问题

    以前一直用的方法都是: a {outline: none;star:expression(this.onFocus=this.blur());} 后来发现有瑕疵,不完美.体现在页面调用JS动作比较频繁 ...

  4. dapper extensions (predicates)

    https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates The predicate system in Dapper Extensio ...

  5. Virtual Box中 CentOS双网卡设置

    Virtual Box中 CentOS双网卡设置:   在Virtual Box中安装CentOS x86-64 6.4(final),配置了双网卡,eth0 为桥接模式 , eth1为内网模式   ...

  6. 从浏览器启动应用程序 - Application URL

    关键字:Browser,Application,URL Protocol,Windows,Mac,IE,Chrome,Safari. OS: Windows 7, OS X Yosemite. Win ...

  7. cwm-recovery自动生成工具

    android发展迅速,刷机已经成了一种习惯,cwm-recovery是必不可少的工具,下面我把自己用的自动生成cwm-recovery的工具发布出来,供友友们交流和学习,欢迎拍砖 已经公开发布在gi ...

  8. ubuntu下下载并安装H265(hm.x.x代码和X265代码)

    H265,现今是High Efficiency Video Coding的别称,详细的概述见维基百科,详细的开发见官方网站. 一.下载并编译官方的测试源码HM.x.x: 1 ubuntu下安装svn: ...

  9. ORA-12838: cannot read/modify an object after modifying it in parallel

    insert /*+ append */ into my_all_objects  select * from my_all_objects; select * from my_all_objects ...

  10. PS 颜色表大全-颜色中文名(1)

    颜色中文名  鸨色#f7acbc 赤白橡#deab8a 油色#817936 绀桔梗#444693 踯躅色#ef5b9c 肌色#fedcbd 伽罗色#7f7522 花色#2b4490 桜色#feeeed ...