Android---06---2中动画效果
1,先看FrameAnimation,此动画是用来实现动态动画就是把一帧帧图片迭代起来
放在drowable中的xml:
<?xml version="1.0" encoding="utf-8"? >
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/ben_window_0001"
android:duration="60"
/> <item android:drawable="@drawable/ben_window_0002"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0003"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0004"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0005"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0006"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0007"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0008"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0009"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0010"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0011"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0012"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0013"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0014"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0015"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0016"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0017"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0018"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0019"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0020"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0021"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0022"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0023"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0024"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0025"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0026"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0027"
android:duration="60"
/>
<item android:drawable="@drawable/ben_window_0028"
android:duration="60"
/> </animation-list>
Activity中:
package com.example.frameanimation; import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} public void startAnimation(View v)
{ Button btn=(Button)v;
//得到动画对象
AnimationDrawable anim=(AnimationDrawable)btn.getBackground(); //启动动画
anim.start();
} }
这样我点击一个Tomcat就会循环的动
然后是补间动画
先看这些xml文件
<? xml version="1.0" encoding="utf-8"?>
<alpha
android:fromAlpha="0.1"
android:toAlpha="1"
android:duration="5000" xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 透明度 0-1 0全然透明 1 全然不透明 -->
</alpha>
<? xml version="1.0" encoding="utf-8"?>
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:duration="500"
android:pivotX="50%"
android:pivotY="50%" android:interpolator="@android:anim/accelerate_interpolator"
android:repeatCount="infinite" android:repeatMode="reverse"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- repeatCount 反复次数 infinite 无限
repeatMode 反复模式
interpolator 加速器
--> </rotate>
<? xml version="1.0" encoding="utf-8"?>
<scale android:fromXScale="0.5"
android:fromYScale="0.5" android:toXScale="2"
android:toYScale="2" android:pivotX="50%"
android:pivotY="50%"
android:duration="200"
android:repeatMode="reverse"
android:repeatCount="infinite"
xmlns:android="http://schemas.android.com/apk/res/android"> </scale>
<!--
fromXScale 1 本身状态
-->
<?xml version="1.0" encoding="utf-8"? >
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0"
android:fromYDelta="0" android:toXDelta="0"
android:toYDelta="80%p" android:duration="100"
android:repeatMode="reverse"
android:repeatCount="infinite"
> </translate>
主文件里的xml
无非就是一张图片加上几个button
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="84dp"
android:src="@drawable/heart" android:id="@+id/myimg"
/> <Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_alignRight="@+id/myimg"
android:text="缩放"
android:onClick="scale"
/> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/myimg"
android:layout_marginLeft="32dp"
android:onClick="alpha"
android:text="alpha" /> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_marginRight="35dp"
android:layout_toLeftOf="@+id/button3"
android:onClick="rotate"
android:text="旋转" /> <Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:text="位移动画"
android:onClick="translate"
/> </RelativeLayout>
然后在Activity中调用这些动画
package com.example.tweenanimation; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView; public class MainActivity extends Activity { private ImageView image; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = (ImageView) findViewById(R.id.myimg);
} // 运行透明动画
public void alpha(View v) {
// 1.载入动画资源
Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.alpha);
// 2.运行动画
image.startAnimation(anim);
} //运行旋转动画
public void rotate(View v) {
Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.rotate); image.startAnimation(anim); }
//缩放动画
public void scale(View v) { Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.scale); image.startAnimation(anim);
} public void translate(View v) { Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.translate); image.startAnimation(anim);
} }
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGM2MzU0MDgxMzY=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
Android---06---2中动画效果的更多相关文章
- Android Acitivy切换平移动画效果实现
1.在anim目录下新建anim文件夹,新建tran_in.xml和tran_out.xml分别表示下一页切换进入,和本页切换出去. 即in表示下一页向左平移,out表示同样向左平移至消失. tran ...
- 漂亮的Android加载中动画:AVLoadingIndicatorView
AVLoadingIndicatorView 包含一组漂亮的Android加载中动画. IOS版本:here. 示例 Download Apk 用法 步骤1 Add dependencies in b ...
- 【转】Android 实现蘑菇街购物车动画效果
原文出处:http://blog.csdn.net/wangjinyu501/article/details/38400479 1.思路 目前想到两种方式实现这种效果,一是使用Tween动画,直截 ...
- Android开发之View动画效果插补器Interpolator
插补器Interpolator 官网描述:An interpolator defines the rate of change of an animation. This allows the bas ...
- Android 之Activity切换动画效果
在Activity中Android提供了overridePendingTransition(int enterAnim,int exitAnim)这个方法用于设置Activity之间切换的动画效果.o ...
- Android 实现蘑菇街购物车动画效果
版本号:1.0 日期:2014.8.6 版权:© 2014 kince 转载注明出处 使用过蘑菇街的用户基本上都知道有一个增加购物车的动画效果,此处不详细描写叙述想知道的能够去下载体验一下. 1 ...
- Android实现控件动画效果
MainActivity.java public class MainActivity extends AppCompatActivity { private ImageView iv; privat ...
- android dialog加载中动画效果
//显示动画 dialog = new Dialog(context, R.style.loading); dialog.setContentView(R.layout.loadinglayout); ...
- Android 为PopupWindow设置动画效果
首先定义显示效果的动画文件: <?xml version="1.0" encoding="utf-8"?> <set xmlns:androi ...
- Android TextView数字增长动画效果
某些app上,新进入一个Activity的时候,上面的一个关键性数字(比如金额)会以一个数字不断变大的动画来显示.刚开始的时候,想到的一个方案是:使用Thead+Handler,给定一个动画总时长与刷 ...
随机推荐
- ReportView控件的使用
ReportView控件的使用Posted on 2012-01-06 17:02 随遇 阅读(3006) 评论(0) 编辑 收藏 最近使用了ReportView控件绑定数据,总结下: 1.在设计器 ...
- Dell Inspiron 7520 安装Ubuntu 14.04 LTS
我的电脑是Dell Inspiron 7520,之前用的Windows 7, 装了虚拟机,再在虚拟机里面装Ubuntu, 电脑一直卡顿,一怒之下,升级了内存,直接16G,然后,还是卡顿,CPU是i5的 ...
- asp.net core 身份认证/权限管理系统简介及简单案例
如今的网站大多数都离不开账号注册及用户管理,而这些功能就是通常说的身份验证.这些常见功能微软都为我们做了封装,我们只要利用.net core提供的一些工具就可以很方便的搭建适用于大部分应用的权限管理系 ...
- 计蒜客 17119.Trig Function-切比雪夫多项式+乘法逆元 (2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F)
哈哈哈哈哈哈哈哈哈哈哈哈,终于把这道题补出来了_(:з」∠)_ 来写题解啦. _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ 哈哈哈哈哈哈,从9月16日打了这 ...
- 51nod 1090 3个数和为0【二分】
1090 3个数和为0 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 给出一个长度为N的无序数组,数组中的元素为整数,有正有负包括0,并互不相等.从 ...
- 新疆大学ACM-ICPC程序设计竞赛五月月赛(同步赛)- XOR(二进制使用)
链接:https://www.nowcoder.com/acm/contest/116/H来源:牛客网 题目描述 Once there was a king called XOR, he had a ...
- 【hdu1150】【Machine Schedule】二分图最小点覆盖+简单感性证明
(上不了p站我要死了,侵权度娘背锅) 题目大意 有两台机器A和B以及N个需要运行的任务.每台机器有M种不同的模式,而每个任务都恰好在一台机器上运行.如果它在机器A上运行,则机器A需要设置为模式ai,如 ...
- C++中数据对齐问题。struct、union、enum,类继承。再谈sizeof()
首先是struct,在C++中,结构体其实和class有很大的相似了.但是有一点不同的是,struct默认是public,而class中是private. 当然,struct继承等用法也是可以的. 共 ...
- Entity Framework贪婪加载筛选问题
先说一下代码北京,现在有一个Table类,代表桌子,然后Tale里面级联这一系列订单Order,现在要获取这个Table中没有完成的订Order,用完include之后居然发现不知道该怎么写,上网找了 ...
- linux下批量更改一个目下的目录和文件的权限
对于网站目录我们一般设置目录的权限是755, 而文件的权限是644 ,上传目录另设 比如我们要设置web目录下的所有目录的权限是755,文件的目录是644,那么我们可以批量修改吗?答案是肯定的, 就 ...