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 ...
随机推荐
- box2d 遍历世界中 body 的方法
大家都知道,循环遍历有很多方法,在box2d中大家普遍使用while和for循环来遍历世界,那什么时候使用for,什么时候使用while呢? 当循环中不设计body删除的时候,使用for循环,即: C ...
- Mysql迁移工具在生产环境下的使用
在产品迭代开发发布过程中,由于业务需求的增加,数据库难免会有结构调整等操作. 在每个版本发布过程中怎么控制每个版本server端程序与数据库版本保持一致,以及数 据库升级.回滚等操作. 本博文宅鸟将向 ...
- php spl
最近在重构后台,自写rbac,发现自己在设计模式方面尤为欠缺,没有一个长远的目光,所以打算静下心来看一看自己平时不关注的功能,spl就是其中之一. spl是Standard PHP Library(P ...
- PHP生成二维码库phpqrcode
Description PHP QR Code is open source (LGPL) library for generating QR Code, 2-dimensional barcode. ...
- sql server备份还原数据时的问题记录
1.关于“因为数据库正在使用,所以无法获得对数据库的独占访问权”的最终解决方案 关键SQL语句: ALTER DATABASE [datebase] SET OFFLINE WITH ROLLBACK ...
- Delphi For Android 开发笔记 1 - 开发工具介绍
在开始前,推荐喜欢delphi或者pascal的朋友,如果想将原来Windows的软件工程移植到Android,可使用CodeTyphon+Delphi XE7进行开发. 1.CodeTyphon C ...
- GUID,UUID
<? class System { function currentTimeMillis() { list($usec, $sec) = explode(" ",microt ...
- C#创建、读取和修改Excel
// Namespaces, Variables, and Constants using System; using System.Configuration; using System.Data; ...
- How to get the underlying SSRS Report Query, reset query , add your own ranges and execute report [AX2012]
Below is the small code snippet to get the underlying query of the SSRS report, reset query, prompt ...
- Ubuntu 下安装 Oracle JDK
sudo add-apt-repository ppa:webupd8team/javasudo apt-get updatesudo apt-get install oracle-java8-ins ...