android动画效果演示
第一种:TranslateAnimation 动画效果演示:
public void move(View view)
{
// 传统动画效果
TranslateAnimation animation=new TranslateAnimation(0, 500, 0, 0);
// 时间
animation.setDuration(500);
// 设置移动后的位置不恢复
animation.setFillAfter(true);
ImageButton img=(ImageButton) findViewById(R.id.img);
TextView tv=(TextView) findViewById(R.id.lab);
// 设置动画效果 控件
img.startAnimation(animation);
tv.startAnimation(animation);
Toast.makeText(this, "移动时间", Toast.LENGTH_SHORT).show();
}
XML 配置按钮时间
<Button
android:gravity="center"
android:layout_marginTop="500sp"
android:layout_marginStart="30sp"
android:layout_marginLeft="30sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="移动按钮"
android:id="@+id/btn"
android:onClick="move"
使用-------------使用ObjectAnimator----------360
// -------------使用ObjectAnimator----------
ObjectAnimator animator=new ObjectAnimator();
// animator.ofFloat(img, "translationY", 0,100).setDuration(1000).start();
if(flag)
{
animator.ofFloat(img, "Y", 0,300).setDuration(1000).start();
animator.ofFloat(img, "X", 0,300).setDuration(1000).start();
animator.ofFloat(img, "rotation", 0,360).setDuration(1000).start();
flag=false;
}
else
{
animator.ofFloat(img, "Y", 300,0).setDuration(1000).start();
animator.ofFloat(img, "X", 300,0).setDuration(1000).start();
animator.ofFloat(img, "rotation", 3600,0).setDuration(1000).start();
flag=true;
}
PropertyValuesHolder对象的使用
/**
* 跟上面不同的是代码优化了
*/
public void propteValueHolderDemo()
{
ImageButton img=(ImageButton) findViewById(R.id.img);
PropertyValuesHolder pro1=PropertyValuesHolder.ofFloat("rotation", 0,360F);
PropertyValuesHolder pro2=PropertyValuesHolder.ofFloat("x", 0,300);
PropertyValuesHolder pro3=PropertyValuesHolder.ofFloat("y", 0,300);
ObjectAnimator.ofPropertyValuesHolder(img,pro1,pro2,pro3).setDuration(1000).start();
}
/**
* 按顺序 演示动画效果
*/
public void PlaySequentiallyDemo()
{
ImageButton img=(ImageButton) findViewById(R.id.img);
ObjectAnimator animator1= ObjectAnimator.ofFloat("img","X",0,360F);
ObjectAnimator animator2= ObjectAnimator.ofFloat("img","Y",0,360F); AnimatorSet set=new AnimatorSet();
set.playSequentially(animator1,animator2);
set.setDuration(1000);
set.start(); }
android动画效果演示的更多相关文章
- Android动画效果之Property Animation进阶(属性动画)
前言: 前面初步认识了Android的Property Animation(属性动画)Android动画效果之初识Property Animation(属性动画)(三),并且利用属性动画简单了补间动画 ...
- Android动画效果之自定义ViewGroup添加布局动画
前言: 前面几篇文章介绍了补间动画.逐帧动画.属性动画,大部分都是针对View来实现的动画,那么该如何为了一个ViewGroup添加动画呢?今天结合自定义ViewGroup来学习一下布局动画.本文将通 ...
- Android动画效果之初识Property Animation(属性动画)
前言: 前面两篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画).Frame Animation(逐帧动画)Andr ...
- Android动画效果之Frame Animation(逐帧动画)
前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...
- Android动画效果之Tween Animation(补间动画)
前言: 最近公司项目下个版本迭代里面设计了很多动画效果,在以往的项目中开发中也会经常用到动画,所以在公司下个版本迭代开始之前,抽空总结一下Android动画.今天主要总结Tween Animation ...
- HTML5 Canvas动画效果演示
HTML5 Canvas动画效果演示 主要思想: 首先要准备一张有连续帧的图片,然后利用HTML5 Canvas的draw方法在不同的时间 间隔绘制不同的帧,这样看起来就像动画在播放. 关键技术点: ...
- HTML5 Canvas动画效果演示 - 流浪的鱼 - 博客频道 - CSDN.NET
HTML5 Canvas动画效果演示 - 流浪的鱼 - 博客频道 - CSDN.NET HTML5 Canvas动画效果演示
- 200多种Android动画效果的强悍框架
admin 发布于2015-10-23 14:33 363/68015 [精品推荐]200多种Android动画效果的强悍框架,太全了,不看这个,再有动画的问题,不理你了^@^ 功能模块和技术方案 只 ...
- Android动画效果 translate、scale、alpha、rotate 切换Activity动画 控件位置调整
2011.10.28注:如果需要控件停在动画后的位置,需要设置android:fillAfter属性为true,在set节点中.默认在动画结束后回到动画前位置.设置android:fillAfter后 ...
随机推荐
- HDU OJ 5441 Travel 2015online E
题目:click here 题意: 有个很暴躁的人,想坐车旅行n个城市.连接城市共有m条路(双向).他坐在车上很不爽,每次最多忍耐x分钟.但是每站下车他又可以休息(重新计时).总共有q次询问.问途中有 ...
- VS2010使用DX报错 VS报错之混合模式程序集是针对“v1.1.4322”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集。
更改项目的app.config内容为以下内容 目的是开启对低版本的NETFWK支持 其实出现混合模式集的问题不只是在V1.1.4322这个版本上,在查询解决方案时发现,但凡程序集版本发生改变时,都有可 ...
- (Problem 62)Cubic permutations(待续)
The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 ...
- 读书笔记: nodejs API 参考
>> bufferBuffer对象是全局对象Buffer支持的编码方式:ascii, utf8, base64, binarynew Buffer(size)new Buffer(arra ...
- 什么是PCB改板及PCB改板应注意的问题
PCB改板是指在保持原有功能一致的前提下,对原有产品设计及电路板布局走线设计的基础上进行整改设计,调整板上器件布局与线路走向,实现电子产品重新设计研发,同时又可以规避知识产权等纠纷,加快新产品研发速度 ...
- MSSQL SERVER 2008 R2 无法连接到数据库,用户sa登录失败,错误:18456
原因:勾选了强制实施密码策略,但是设置的密码很简单依然可以,比如:123456 这是为什么?原来,这个功能要用到NetValidatePasswordPolicy() API这个函数. (该功能只有在 ...
- C/C++ 基础教程
自从做IOS后,就比较少用纯C++的方式写代码了,因为Obj-C的代码风格和C++的风格还是有一点区别的.怕自己忘记了C/C++的基础.整理了一些C/C++基础的网站,供大家学习C/C++ ...
- java代码发送JSON格式的httpPOST请求
package com.test; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOE ...
- CodeForces 448
A:Rewards: 题目链接:http://codeforces.com/problemset/problem/448/A 题意:Bizon有a1个一等奖奖杯,a2个二等奖奖杯,a3个三等奖奖杯,b ...
- C#静态方法
C#静态方法 学习C#静态函数及变量的一个精典例子与代码 (1)用于对静态字段.只读字段等的初始化. (2)添加static关键字,不能添加访问修饰符,因为静态构造函数都是私有的. (3)类的 ...