android 后台代码设置动画
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 后台代码设置动画的更多相关文章
- Android中代码设置RadioButton的高端技巧
不知道怎么起标题,就这样了. 目前主要讲两个方面内容: 代码方式 设置RadioButton的 android:button . android:background 等属性为 @null : 代码方 ...
- Android 为PopupWindow设置动画效果
首先定义显示效果的动画文件: <?xml version="1.0" encoding="utf-8"?> <set xmlns:androi ...
- Android -- java代码设置margin
我们平常可以直接在xml里设置margin,如: <ImageView android:layout_margin="5dip" android:src="@dra ...
- Android 通过代码设置radiobutton不同方位图标的两种方法
更换radiobutton中的图片在xml中很好设置,但对于初学者如何在代码中设置还是不容易找的.没法子,通过看原版api找到两个方法,setCompoundDrawables和setCompound ...
- Android 用代码设置Shape,corners,Gradient
网上查找资料 记录学习 int strokeWidth = 5; // 3dp 边框宽度 int roundRadius = 15; // 8dp 圆角半径 int strokeColor = Col ...
- android 通过代码设置drawableLeft
/** * * @desc 设置左边图标 * @param @param drw * @return void */ public void setAlertLeftIcon(Drawable drw ...
- Android小代码——设置全屏
1: public class MainActivity extends Activity { 2: @Override 3: public void onCreate(Bundle savedIns ...
- WPF 后台代码做 TranslateTransform 的动画
本文告诉大家,在后台代码,对 TranslateTransform 做动画的方法 今天小伙伴问我一个问题,说为什么相同的代码,如果设置到按钮上,是可以让按钮的某个属性变更,但是如果设置给 Transl ...
- Android中xml设置Animation动画效果详解
在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...
随机推荐
- iOS开发优化的25个方案
写在前面 本文来自iOS Tutorial Team 的 Marcelo Fabri,他是Movile的一名 iOS 程序员.这是他的个人网站:http://www.marcelofabri.com/ ...
- VS2013添加NuGet的方法
1.工具->扩展和更新->联机 2.右上角搜索框搜索NuGet,选择NuGet Package Manager for Visual Studio 2013,安装后重启VS 下面通过添加N ...
- 利用Jquery处理跨域请求
在项目制作过程中,可能会用到ajax来提高用户体验,这里终于研究出来,利用jquery来进行跨域请求,在用$.getJSON这个方法时,前台页面中需这样写 $.getJSON(“需要提交处理的url? ...
- Creating a Unique File Name
If you are working with files or file attachments in PeopleCode, you will typically want to create a ...
- php 安装xdebug扩展
php 扩展获取地址 http://pecl.php.net/package/ 编译安装的过程 wget http://pecl.php.net/get/xdebug-2.2.2.tgz tar -z ...
- LotusPhp起步:经典的HelloWorld
写了几篇LotusPhp,一直没有跑个程序,感觉好像步骤有点错,所以先上个经典的Demo,HelloWorld吧 先按推荐目录建好文件夹,如果懒的建,下面有下载的Demo包,解压就可以用,因为简单,也 ...
- [Linux] Ubuntu Server 12.04 LTS 平台上搭建WordPress(Nginx+MySql+PHP) Part II
接着上一节继续搭建我们的LNMP平台,接下来我们安装PHP相关的服务 sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5- ...
- SBM is Not Sale And Run Company
data = """ Well,We will bet you dollars to donuts,there are so many crusher provider ...
- MIS2000 Lab,我的IT人生与职场--从零开始的前十五年 与 我的微创业
http://www.dotblogs.com.tw/mis2000lab/archive/2014/09/16/ithome_2014_ironman.aspx [IT邦幫忙]鐵人賽 -- MIS2 ...
- 第五节:什么导致Finalize方法被调用
Finalize方法在垃圾回收结束时被调用,下面有5种事件会导致开始垃圾回收 1.第0代已满 第0代已满,垃圾回收会自动开始.该事件是目前导致Finalize方法被调用的最常见的一种方式,因为虽 ...
