属性动画PropertyAnimation
xml实现
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together" >
<objectAnimator
android:duration="3000"
android:propertyName="alpha"
android:valueFrom="0"
android:valueTo="1" >
</objectAnimator>
<objectAnimator
android:duration="4000"
android:propertyName="scaleX"
android:valueFrom="0.5"
android:valueTo="1"
android:valueType="floatType" >
</objectAnimator>
<objectAnimator
android:duration="5000"
android:propertyName="scaleY"
android:valueFrom="0.5"
android:valueTo="1" >
</objectAnimator>
</set>
Animator animator = AnimatorInflater.loadAnimator(this, R.animator.set);
animator.setTarget(imageview);
animator.start();
下面是java代码实现
// 透明度属性动画
public void alpha(View view) {
ObjectAnimator object_anim = ObjectAnimator.ofFloat(imageview, "alpha", 0,1.0f);
//设置持续时间。
object_anim.setDuration(3000);
//启动动画。.
object_anim.start();
}
//缩放属性动画。
public void scale(View view) {
ObjectAnimator scale_anim = ObjectAnimator.ofFloat(imageview, "scaleX", 0.5f,2);
scale_anim.setDuration(5000);
scale_anim.setRepeatCount(0);
ObjectAnimator scale_anim_y = ObjectAnimator.ofFloat(imageview, "scaleY", 0.5f,2);
scale_anim_y.setDuration(5000);
scale_anim_y.setRepeatCount(0);
scale_anim_y.start();
scale_anim.start();
}
//位移属性动画
public void translate(View view) {
ObjectAnimator translate_anim = ObjectAnimator.ofFloat(imageview, "shadowDx", 0,200);
translate_anim.setDuration(3000);
translate_anim.setRepeatCount(0);
translate_anim.start();
}
//旋转属性动画
public void rotate(View view) {
ObjectAnimator translate_anim = ObjectAnimator.ofFloat(imageview, "translateX", 0,200);
}
*属性动画的监听方法
animator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator animation) {
//跳转。
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
startActivity(intent);
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
}
});
布局
属性动画PropertyAnimation的更多相关文章
- Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)
1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...
- Android中PropertyAnimation属性动画详解(一)
在之前的文章中已经讲了帧动画frame-by-frame animation和补间动画tweened animation,其实这两种动画原理好简单,都是按照预先固定的动画模式来播放的,帧动画将一张张单 ...
- Android笔记(六十五) android中的动画——属性动画(propertyanimation)
补间动画只能定义起始和结束两个帧在“透明度”.“旋转”.“倾斜”.“位移”4个方面的变化,逐帧动画也只能是播放多个图片,无法满足我们日常复杂的动画需求,所以谷歌在3.0开始,推出了属性动画(prope ...
- 使用属性动画 — Property Animation
属性动画,就是通过控制对象中的属性值产生的动画.属性动画是目前最高级的2D动画系统. 在API Level 11中添加.Property Animation号称能控制一切对象的动画,包括可见的和不可见 ...
- 使用属性动画 — Property Animation
属性动画,就是通过控制对象中的属性值产生的动画.属性动画是目前最高级的2D动画系统. 在API Level 11中添加.Property Animation号称能控制一切对象的动画,包括可见的和不可见 ...
- Android动画基础——属性动画(Property Animation)
本篇涉及例子下载:Github 本篇讲android 3.0引入的属性动画框架,上篇写视图动画View Animation时就说过ViewAnimation的缺点,那就是动画作用的是view本身的视觉 ...
- Android动画效果之Property Animation进阶(属性动画)
前言: 前面初步认识了Android的Property Animation(属性动画)Android动画效果之初识Property Animation(属性动画)(三),并且利用属性动画简单了补间动画 ...
- Android动画效果之初识Property Animation(属性动画)
前言: 前面两篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画).Frame Animation(逐帧动画)Andr ...
- Android属性动画
这几天看郭神的博客 Android属性动画完全解析(上),初识属性动画的基本用法之后,我自己突然想实现一种动画功能,就是我们在携程网.阿里旅行等等手机APP端买火车票的时候,看到有选择城市,那么就有出 ...
随机推荐
- javascript单例模式的理解
javascript单例模式的理解 阅读目录 理解单例模式 使用代理实现单例模式 理解惰性单例 编写通用的惰性单例 单例模式使用场景 回到顶部 理解单例模式 单例模式的含义是: 保证一个类只有一个实例 ...
- 用Prime31实现Google Play In-App-Blling
Android开发者想在海外赚钱,接入Google Play是不二选择,然而一堆英文文档对于像我这样的英语四级都木有过的可谓是苦恼之极.近段时间因工作需要研究了Unity接入Google Play的整 ...
- bitbucket新建分支
/workspace/ott_app_store:fetch-xml$ git branch edit_package_page /workspace/ott_app_store:fetch-xml$ ...
- Linux and the Unix Philosophy (Linux/Unix设计思想)
http://www.iwangzheng.com/ 大约30年前,当美国人边开着大型轿车边享受着其他国家民众的羡慕目光时,大众汽车却在美国开展了一项主题为“小即是美”的广告营销活动.那时,美国人对大 ...
- 转:github使用教程(重装系统后遇到问题该文章帮我解决了)
github简单使用教程 时间:2012 年 5 月 29 日 6 条评论 分类:学习笔记 , 网络 , 软件 目录 1.注册账户以及创建仓库 2.安装客户端msysgit 3.配置Git 4.提交. ...
- ZeroMQ之Push与Pull (Java)
本系列文章均转自:http://blog.csdn.net/kobejayandy/article/details/20163431 在ZeroMQ中并没有绝对的服务端与客户端之分,所有的数据接收与发 ...
- Javascript之十大常用原理性样例大总结
案例一:全选等 运用知识点:ondblclick=()| onclick | 寻找标签属性及判断和函数的应用
- 《C#高级编程》学习笔记------C#中的委托和事件(续)
本文转载自张子阳 目录 为什么要使用事件而不是委托变量? 为什么委托定义的返回值通常都为void? 如何让事件只允许一个客户订阅?(事件访问器) 获得多个返回值与异常处理 委托中订阅者方法超时的处理 ...
- First Position of Target
For a given sorted array (ascending order) and a target number, find the first index of this number ...
- object-c面向对象2
我们知道在c#中有访问私有成员变量的get 和set方法.这个目的是用来公开实力对象的私有变量.我看了下ios的访问修饰符.也就是private,public,protected.这些基本上都和c# ...