1、设置旋转动画

final RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,0.5f);

 animation.setInterpolator(new LinearInterpolator());  // LinearInterpolator 表示均匀速率
animation.setDuration(3000);//设置动画持续时间
animation.setRepeatCount(Animation.INFINITE); //表示重复多次,也可以用具体的次数
ll_earn_circle_bg.startAnimation(animation); //ll_earn_circle_bg 是一个LinearLayout控件 2、设置位移动画
/**
* CycleTimes动画重复的次数
* @param CycleTimes
*/
public void shakeAnimation(int CycleTimes) {
if (null == mShakeAnimation) {
mShakeAnimation = new TranslateAnimation(0, 10, 0, 0);
mShakeAnimation.setInterpolator(new CycleInterpolator(CycleTimes)); //设置速度,,CycleInterpolator某种数学上的曲线,即摇晃的速率曲线化
mShakeAnimation.setDuration(1500);
mShakeAnimation.setRepeatMode(Animation.REVERSE);//设置反方向执行
}
tv_curmoney.startAnimation(mShakeAnimation); //tv_curmoney是一个textview控件
}
3、设置缩放动画
/** 设置缩放动画 */
final ScaleAnimation animation =new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setDuration(2000);//设置动画持续时间
iv_go_rank.startAnimation(animation); // iv_go_rank 是一个imageview控件

关于速率的介绍:

在xml文件中定义Interpolator

android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true"

这样所有的Animation共用一个Interpolator。

在代码中用代码设置如下

anim.setInterpolator(new AccelerateInterpolator());

在new一个AnimationSet中传入true则所有的Animation共用Interpolator。


android 后台代码设置动画的更多相关文章

  1. Android中代码设置RadioButton的高端技巧

    不知道怎么起标题,就这样了. 目前主要讲两个方面内容: 代码方式 设置RadioButton的 android:button . android:background 等属性为 @null : 代码方 ...

  2. Android 为PopupWindow设置动画效果

    首先定义显示效果的动画文件: <?xml version="1.0" encoding="utf-8"?> <set xmlns:androi ...

  3. Android -- java代码设置margin

    我们平常可以直接在xml里设置margin,如: <ImageView android:layout_margin="5dip" android:src="@dra ...

  4. Android 通过代码设置radiobutton不同方位图标的两种方法

    更换radiobutton中的图片在xml中很好设置,但对于初学者如何在代码中设置还是不容易找的.没法子,通过看原版api找到两个方法,setCompoundDrawables和setCompound ...

  5. Android 用代码设置Shape,corners,Gradient

    网上查找资料 记录学习 int strokeWidth = 5; // 3dp 边框宽度 int roundRadius = 15; // 8dp 圆角半径 int strokeColor = Col ...

  6. android 通过代码设置drawableLeft

    /** * * @desc 设置左边图标 * @param @param drw * @return void */ public void setAlertLeftIcon(Drawable drw ...

  7. Android小代码——设置全屏

    1: public class MainActivity extends Activity { 2: @Override 3: public void onCreate(Bundle savedIns ...

  8. WPF 后台代码做 TranslateTransform 的动画

    本文告诉大家,在后台代码,对 TranslateTransform 做动画的方法 今天小伙伴问我一个问题,说为什么相同的代码,如果设置到按钮上,是可以让按钮的某个属性变更,但是如果设置给 Transl ...

  9. Android中xml设置Animation动画效果详解

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

随机推荐

  1. [原]My first Python

    我的第一个Python程序: print 'hello world' raw_input ("print any key to continue...") 在python3.4下应 ...

  2. 破解source insignt方法

    source insignt版本:官网3.5版本 方法:在桌面建立一个文本文档,将下面内容拷贝进去,保存为.reg文件(注意拓展名问题,自己设置),然后双击即可. win7  64bit Window ...

  3. 安装zabbix

    安装zabbix 1. 准备好lamp架构(安装好mysql,php) 2.在数据库中授权: MariaDB [(none)]> create database zabbix charset u ...

  4. c#高效比对大量图片

    比较图片的方法 以前传统的比较方式是遍历图片中的每一个像素,然后进行比对.这样的比对在少量图片的比对上虽然效率低一点,但是也没有什么不好.但是在大量图片比对的时候,过长的反应时间和对服务器比较高的消耗 ...

  5. jquery源码学习--iceDog

    /** * @FileName : iceDog * @Author : PheonixHkbxoic * @Mail : hkbxoic@gmail.com * @DateTime : 2016-0 ...

  6. Ubuntu CTRL+ALT+F1~F6 进入命令模式后不支持中文显示的解决办法

    前言 我在实验进入linux系统启动xwindow server而不启动KDE GNOME等桌面系统时遇到的问题.只启动x server而不启动桌面系统,在xserver之上运行一个全屏的图形界面程序 ...

  7. php使用base64加密解密图片

    php使用base64加密解密图片的实例代码. 例子: <?php //文件名:base64.php $data="/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAB ...

  8. 将raw里面的数据库文件写入到data中

    package com.city.list.db; import java.io.File; import java.io.FileNotFoundException; import java.io. ...

  9. Ubuntu 12.04 添加新用户并启用root登录

    启动root sudo passwd 输入密码 输入root 新密码并重复 su 切换root 添加用户比如hduser 修改密码hduserchmod u+w /etc/sudoersvi sudo ...

  10. Learning Scrapy笔记(一)- Scrapy简单介绍

    Scrapy简述 Scrapy十一个健壮的,用来从互联网上抓取数据的web框架,Scrapy只需要一个配置文件就能组合各种组件和配置选项,并且Scrapy是基于事件(event-based)的架构,使 ...